Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

remove positional arguments from CLI #59

Merged
merged 10 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 68 additions & 44 deletions docs/man/antler-proj.1
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
.\" Automatically generated by Pandoc 2.9.2.1
.\" Automatically generated by Pandoc 3.1.2
.\"
.\" Define V font for inline verbatim, using C font in formats
.\" that render this, and otherwise B font.
.ie "\f[CB]x\f[]"x" \{\
. ftr V B
. ftr VI BI
. ftr VB B
. ftr VBI BI
.\}
.el \{\
. ftr V CR
. ftr VI CI
. ftr VB CB
. ftr VBI CBI
.\}
.TH "antler-proj" "1" "March 09, 2023" "antler-proj 1.0.0" "User Manual"
.hy
.SH NAME
.PP
antler-proj - Antler Project Management System
.SH SYNOPSIS
.PP
\f[C]antler-proj <command> [<args>]\f[R]
\f[V]antler-proj <command> [<args>]\f[R]
.SH DESCRIPTION
.PP
\f[B]Antler Project Management System\f[R] is a set of libraries and
Expand All @@ -17,34 +31,31 @@ tools to help users successfully develop smart contracts.
This is a general help text which prints when antler-proj runs without a
command or with key \[em]help.
.PP
\f[B]Example: \f[CB]antler-proj --help\f[B]\f[R]
\f[B]Example: \f[VB]antler-proj --help\f[B]\f[R]
.PP
Each command has its own help which prints when the command runs with
key \[em]help.
.PP
\f[B]Example: \f[CB]antler-proj init --help\f[B]\f[R]
\f[B]Example: \f[VB]antler-proj init --help\f[B]\f[R]
.PP
Below is described a full list of all possible commands and their
possible arguments
.PP
\f[B]init\f[R] command creates a new project.
Creating the directory tree, a \f[C]project.yaml\f[R] file and
Creating the directory tree, a \f[V]project.yaml\f[R] file and
initializes it.
.IP
.nf
\f[C]
Command arguments:
<path> Path to the root of the project. Here a \[ga]project.yaml\[ga] file will be created
<project_name> Name of the project
[version] Version of the project. Default version is 0.0.1
-h,--help Print this help message and exit
-p <path> Path to the root of the project.
-n <project_name> The name of the project.
-v <version> The version to store in the project file.
-p,--path Path to the root of the project. Here a \[ga]project.yaml\[ga] file will be created. Default is ./<name>.
-n,--name The name of the project.
-v,--version The version to store in the project file. Default version is 0.0.1
\f[R]
.fi
.PP
\f[B]Example: \f[CB]antler-proj init ./project hello_world 0.1\f[B]\f[R]
\f[B]Example: \f[VB]antler-proj init ./project hello_world 0.1\f[B]\f[R]
.PP
\f[B]add\f[R] command adds an app, dependency, library or test to your
project.
Expand All @@ -53,13 +64,12 @@ project.
\f[C]
Command arguments:
-h,--help Print this help message and exit
-p <path> This must be the path to the \[ga]project.yml\[ga] or the path containing it.
[path] Path to the root of the project.
-p,--path This must be the path to the \[ga]project.yaml\[ga] or the path containing it. Default is current directory.
<app,lib,dep> Type of an entity to work with
\f[R]
.fi
.PP
\f[B]Example: \f[CB]antler-proj add ./project app\f[B]\f[R]
\f[B]Example: \f[VB]antler-proj add ./project app\f[B]\f[R]
.PP
\f[B]update\f[R] command updates an app, dependency, library or test to
your project.
Expand All @@ -68,13 +78,12 @@ your project.
\f[C]
Command arguments:
-h,--help Print this help message and exit
-p <path> This must be the path to the \[ga]project.yml\[ga] or the path containing it.
[path] Path to the root of the project.
-p,--path This must be the path to the \[ga]project.yaml\[ga] or the path containing it. Default is current directory.
<app,lib,dep> Type of an entity to work with
\f[R]
.fi
.PP
\f[B]Example: \f[CB]antler-proj update ./project app\f[B]\f[R]
\f[B]Example: \f[VB]antler-proj update ./project app\f[B]\f[R]
.PP
\f[B]remove\f[R] command removes an app, dependency, library or test
from your project.
Expand All @@ -83,17 +92,16 @@ from your project.
\f[C]
Command arguments:
-h,--help Print this help message and exit
-p <path> This must be the path to the \[ga]project.yml\[ga] or the path containing it.
[path] Path to the root of the project.
-p,--path This must be the path to the \[ga]project.yaml\[ga] or the path containing it. Default is current directory.
<app,lib,dep> Type of an entity to work with
\f[R]
.fi
.PP
\f[B]Example: \f[CB]antler-proj remove ./project app\f[B]\f[R]
\f[B]Example: \f[VB]antler-proj remove ./project app\f[B]\f[R]
.PP
\f[B]populate\f[R] command loads existing information about the project
starting from the root project.yaml file as described in the chapter
\f[C]\[dq]Loading of a project\[dq]\f[R] in the User\[cq]s guide.
\f[V]\[dq]Loading of a project\[dq]\f[R] in the User\[cq]s guide.
.IP
.nf
\f[C]
Expand All @@ -106,12 +114,11 @@ Downloads all the updates in a way depending on where it is located.
\f[C]
Command arguments:
-h,--help Print this help message and exit
-p <path> This must be the path to the \[ga]project.yml\[ga] or the path containing it.
[path] Path to the root of the project.
-p,--path This must be the path to the \[ga]project.yml\[ga] or the path containing it. Default is current directory.
\f[R]
.fi
.PP
\f[B]Example: \f[CB]antler-proj populate ./project\f[B]\f[R]
\f[B]Example: \f[VB]antler-proj populate ./project\f[B]\f[R]
.PP
\f[B]validate\f[R] command performs a check of the project to ensure
that all data that describes the project is correct.
Expand All @@ -130,12 +137,12 @@ exist and if it is possible to download all remote dependencies.
\f[C]
Command arguments:
-h,--help Print this help message and exit
-p <path> Path to the root of the project.
-p,--path This must be the path to the \[ga]project.yml\[ga] or the path containing it. Default is current directory.
-V,--verbose Verbose output.
\f[R]
.fi
.PP
\f[B]Example: \f[CB]antler-proj validate ./project\f[B]\f[R]
\f[B]Example: \f[VB]antler-proj validate ./project\f[B]\f[R]
.PP
\f[B]build\f[R] command builds all applications described in the
project.yaml, their dependencies and tests.
Expand All @@ -144,32 +151,49 @@ project.yaml, their dependencies and tests.
\f[C]
Command arguments:
-h,--help Print this help message and exit
-p <path> This must be the path to the \[ga]project.yml\[ga] or the path containing it.
[path] Path to the root of the project.
-p,--path This must be the path to the \[ga]project.yml\[ga] or the path containing it. Default is current directory.
\f[R]
.fi
.PP
\f[B]Example: \f[CB]antler-proj build ./project\f[B]\f[R]
\f[B]Example: \f[VB]antler-proj build ./project\f[B]\f[R]
.PP
\f[B]\f[CB]--version\f[B]\f[R] Returns the version of antler-proj
application \f[B]Example: \f[CB]antler-proj --version\f[B]\f[R]
\f[B]\f[VB]--version\f[B]\f[R] Returns the version of antler-proj
application \f[B]Example: \f[VB]antler-proj --version\f[B]\f[R]
.SH EXAMPLES
.IP
.nf
\f[C]
antler-proj add app MyApp C++ \[rs]\[rs]-O2
antler-proj add app -n MyApp -l C++ \[dq]\[rs]-O2 -WError\[dq] \[rs]\[rs]-s
antler-proj add lib MyLib C++ \[rs]\[rs]-O2 \[dq]\[rs]-s\[dq]
antler-proj add dep MyApp MyDep
antler-proj add app -n MyApp -l C++ --comp \[rs]\[rs]-O2
antler-proj add app --name MyApp --langl C++ --comp \[rs]\[rs]-O2
antler-proj add app -n MyApp -l C++ --comp \[dq]\[rs]-O2 -WError\[dq] --limk \[rs]\[rs]-s
antler-proj add app --name MyApp --lang C++ --comp \[dq]\[rs]-O2 -WError\[dq] --limk \[rs]\[rs]-s
antler-proj add lib -n MyLib -l C++ --comp \[rs]\[rs]-O2 --link \[dq]\[rs]-s\[dq]
antler-proj add lib --name MyLib --lang C++ --comp \[rs]\[rs]-O2 --link \[dq]\[rs]-s\[dq]
antler-proj add dep -o MyApp -d MyDep
antler-proj add dep --obj_name MyApp --dep_name MyDep

antler-proj build -j3
antler-proj init MyProjectName 1.0.0
antler-proj populate ./path-to-project
antler-proj remove app MyApp
antler-proj remove lib MyLib
antler-proj remove dep MyDep MyApp
antler-proj update app MyApp C++ \[rs]\[rs]-O2
antler-proj update lib MyLib C++ \[rs]\[rs]-O2 \[dq]\[rs]-s\[dq]
antler-proj update dep MyDep -l AntelopeIO/my_dep
antler-proj build --jobs 3

antler-proj init -n MyProjectName -v 1.0.0
antler-proj init --name MyProjectName --version 1.0.0

antler-proj populate -p ./path-to-project
antler-proj populate --path ./path-to-project

antler-proj remove app -n MyApp
antler-proj remove app --name MyApp
antler-proj remove lib -n MyLib
antler-proj remove lib --name MyLib
antler-proj remove dep -d MyDep -o MyApp
antler-proj remove dep --dep_name MyDep --obj_name MyApp

antler-proj update app -n MyApp -l C++ --comp \[rs]\[rs]-O2
antler-proj update app --name MyApp --lang C++ --comp \[rs]\[rs]-O2
antler-proj update lib -n MyLib -l C++ --comp \[rs]\[rs]-O2 --link \[dq]\[rs]-s\[dq]
antler-proj update lib --name MyLib --lang C++ --comp \[rs]\[rs]-O2 --link \[dq]\[rs]-s\[dq]
antler-proj update dep -u https://github.com/AntelopeIO/my_dep
antler-proj update dep --dep_name MyDepCustomName --dep_url C++ https://github.com/AntelopeIO/my_dep
antler-proj validate
\f[R]
.fi
Expand Down
68 changes: 39 additions & 29 deletions docs/man/antler-proj.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,10 @@ Below is described a full list of all possible commands and their possible argum

```
Command arguments:
<path> Path to the root of the project. Here a `project.yaml` file will be created
<project_name> Name of the project
[version] Version of the project. Default version is 0.0.1
-h,--help Print this help message and exit
-p <path> Path to the root of the project.
-n <project_name> The name of the project.
-v <version> The version to store in the project file.
-p,--path Path to the root of the project. Here a `project.yaml` file will be created. Default is ./<name>.
-n,--name The name of the project.
-v,--version The version to store in the project file. Default version is 0.0.1
```
**Example: `antler-proj init ./project hello_world 0.1`**
ScottBailey marked this conversation as resolved.
Show resolved Hide resolved

Expand All @@ -48,8 +45,7 @@ Command arguments:
```
Command arguments:
-h,--help Print this help message and exit
-p <path> This must be the path to the `project.yaml` or the path containing it.
[path] Path to the root of the project.
-p,--path This must be the path to the `project.yaml` or the path containing it. Default is current directory.
<app,lib,dep> Type of an entity to work with
```
**Example: `antler-proj add ./project app`**
Expand All @@ -60,8 +56,7 @@ Command arguments:
```
Command arguments:
-h,--help Print this help message and exit
-p <path> This must be the path to the `project.yaml` or the path containing it.
[path] Path to the root of the project.
-p,--path This must be the path to the `project.yaml` or the path containing it. Default is current directory.
<app,lib,dep> Type of an entity to work with
```
**Example: `antler-proj update ./project app`**
Expand All @@ -72,8 +67,7 @@ Command arguments:
```
Command arguments:
-h,--help Print this help message and exit
-p <path> This must be the path to the `project.yaml` or the path containing it.
[path] Path to the root of the project.
-p,--path This must be the path to the `project.yaml` or the path containing it. Default is current directory.
<app,lib,dep> Type of an entity to work with
```
**Example: `antler-proj remove ./project app`**
Expand All @@ -87,8 +81,7 @@ Command arguments:
```
Command arguments:
-h,--help Print this help message and exit
-p <path> This must be the path to the `project.yml` or the path containing it.
[path] Path to the root of the project.
-p,--path This must be the path to the `project.yml` or the path containing it. Default is current directory.
```
**Example: `antler-proj populate ./project`**

Expand All @@ -103,7 +96,7 @@ Command arguments:
```
Command arguments:
-h,--help Print this help message and exit
-p <path> Path to the root of the project.
-p,--path This must be the path to the `project.yml` or the path containing it. Default is current directory.
-V,--verbose Verbose output.
```
**Example: `antler-proj validate ./project`**
Expand All @@ -113,8 +106,7 @@ Command arguments:
```
Command arguments:
-h,--help Print this help message and exit
-p <path> This must be the path to the `project.yml` or the path containing it.
[path] Path to the root of the project.
-p,--path This must be the path to the `project.yml` or the path containing it. Default is current directory.
```
**Example: `antler-proj build ./project`**

Expand All @@ -125,19 +117,37 @@ Command arguments:
# EXAMPLES

```
antler-proj add app MyApp C++ \\-O2
antler-proj add app -n MyApp -l C++ "\-O2 -WError" \\-s
antler-proj add lib MyLib C++ \\-O2 "\-s"
antler-proj add dep MyApp MyDep
antler-proj add app -n MyApp -l C++ --comp \\-O2
antler-proj add app --name MyApp --langl C++ --comp \\-O2
antler-proj add app -n MyApp -l C++ --comp "\-O2 -WError" --limk \\-s
antler-proj add app --name MyApp --lang C++ --comp "\-O2 -WError" --limk \\-s
antler-proj add lib -n MyLib -l C++ --comp \\-O2 --link "\-s"
antler-proj add lib --name MyLib --lang C++ --comp \\-O2 --link "\-s"
antler-proj add dep -o MyApp -d MyDep
antler-proj add dep --obj_name MyApp --dep_name MyDep

antler-proj build -j3
antler-proj init MyProjectName 1.0.0
antler-proj populate ./path-to-project
antler-proj remove app MyApp
antler-proj remove lib MyLib
antler-proj remove dep MyDep MyApp
antler-proj update app MyApp C++ \\-O2
antler-proj update lib MyLib C++ \\-O2 "\-s"
antler-proj update dep MyDep -l AntelopeIO/my_dep
antler-proj build --jobs 3

antler-proj init -n MyProjectName -v 1.0.0
antler-proj init --name MyProjectName --version 1.0.0

antler-proj populate -p ./path-to-project
antler-proj populate --path ./path-to-project

antler-proj remove app -n MyApp
antler-proj remove app --name MyApp
antler-proj remove lib -n MyLib
antler-proj remove lib --name MyLib
antler-proj remove dep -d MyDep -o MyApp
antler-proj remove dep --dep_name MyDep --obj_name MyApp

antler-proj update app -n MyApp -l C++ --comp \\-O2
antler-proj update app --name MyApp --lang C++ --comp \\-O2
antler-proj update lib -n MyLib -l C++ --comp \\-O2 --link "\-s"
antler-proj update lib --name MyLib --lang C++ --comp \\-O2 --link "\-s"
antler-proj update dep -u https://github.com/AntelopeIO/my_dep
antler-proj update dep --dep_name MyDepCustomName --dep_url C++ https://github.com/AntelopeIO/my_dep
ScottBailey marked this conversation as resolved.
Show resolved Hide resolved
antler-proj validate
```

Expand Down
27 changes: 13 additions & 14 deletions include/antler/project/dependency.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,15 @@ class dependency {

// use default constructors, copy and move constructors and assignments
dependency() = default;
inline dependency(const std::string& name, std::string_view loc, std::string_view tag="",
std::string_view rel="", std::string_view hash="") {
/// @note Check that validate_location() returns true before setting these values.
/// @note It's preferable to populate `tag` with the github commit value than use `rel`. Note that `rel` + `hash` works as well...
/// @param loc The "location" of the project. Possibly a github repo, release or tag archive, or a local file.
/// @param name The name of the dependency. Default is repo name deducted from location.
/// @param tag This is either the github repo tag or commit hash, commit hash being preferable. This may be empty if rel is populated or loc points to an archive.
/// @param rel This is a github repo version. Using a commit hash tag is preferable. This may be empty.
/// @param hash If loc points to an archive, this should be populated with the sha256 hash.
inline dependency(const std::string& loc, const std::string& name = "", const std::string& tag="",
const std::string& rel="", const std::string& hash="") {
set(name, loc, tag, rel, hash);
}

Expand All @@ -37,17 +44,6 @@ class dependency {
dependency& operator=(const dependency&) = default;
dependency& operator=(dependency&&) = default;


/// Sets the internal values (regardless of the validity).
/// @note Check that validate_location() returns true before setting these values.
/// @note It's preferable to populate `tag` with the github commit value than use `rel`. Note that `rel` + `hash` works as well...
/// @param name The name of the dependency.
/// @param loc The "location" of the project. Possibly a github repo, release or tag archive, or a local file.
/// @param tag This is either the github repo tag or commit hash, commit hash being preferable. This may be empty if rel is populated or loc points to an archive.
/// @param rel This is a github repo version. Using a commit hash tag is preferable. This may be empty.
/// @param hash If loc points to an archive, this should be populated with the sha256 hash.
void set(std::string name, std::string_view loc, std::string_view tag, std::string_view rel, std::string_view hash);

/// Get the dependency name.
/// @return The name of this dependency.
[[nodiscard]] inline const std::string& name() const noexcept { return m_name; }
Expand Down Expand Up @@ -147,7 +143,10 @@ class dependency {
ANTLER_TRY_YAML(n, "hash", hash, std::string);
}

private:
private:
/// Sets the internal values (regardless of the validity).
void set(std::string name, std::string_view loc, std::string_view tag, std::string_view rel, std::string_view hash);

std::string m_name; ///< Name of the dependency.
std::string m_loc; ///< Location of the dep: local or remote archive, github repo (https: or org shorthand)
std::string m_tag_or_commit; ///< github tag or commit hash. Always prefer a commit hash.
Expand Down
Loading