diff options
author | Minijackson <minijackson@riseup.net> | 2018-08-02 10:40:35 +0200 |
---|---|---|
committer | Minijackson <minijackson@riseup.net> | 2018-08-02 10:40:35 +0200 |
commit | eb4c557efa38673eba773bda6b71a286d0c3c3b1 (patch) | |
tree | 570600682e6a21f6f5edefab880ef20f4f298e18 /sinksh/syntaxtree.h | |
parent | a24bf3db83d81d7d7677a1f0f750f208d32998a8 (diff) | |
download | sink-eb4c557efa38673eba773bda6b71a286d0c3c3b1.tar.gz sink-eb4c557efa38673eba773bda6b71a286d0c3c3b1.zip |
Add subcommand/parameter/option/flag and automatic help
Diffstat (limited to 'sinksh/syntaxtree.h')
-rw-r--r-- | sinksh/syntaxtree.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/sinksh/syntaxtree.h b/sinksh/syntaxtree.h index ce28548..3d90288 100644 --- a/sinksh/syntaxtree.h +++ b/sinksh/syntaxtree.h | |||
@@ -42,10 +42,33 @@ public: | |||
42 | Syntax(const QString &keyword, const QString &helpText = QString(), | 42 | Syntax(const QString &keyword, const QString &helpText = QString(), |
43 | std::function<bool(const QStringList &, State &)> lambda = std::function<bool(const QStringList &, State &)>(), Interactivity interactivity = NotInteractive); | 43 | std::function<bool(const QStringList &, State &)> lambda = std::function<bool(const QStringList &, State &)>(), Interactivity interactivity = NotInteractive); |
44 | 44 | ||
45 | struct Argument { | ||
46 | QString name; | ||
47 | QString help; | ||
48 | bool required = true; | ||
49 | bool variadic = false; | ||
50 | }; | ||
51 | |||
52 | struct ParameterOptions { | ||
53 | QString name; | ||
54 | QString help; | ||
55 | bool required = false; | ||
56 | }; | ||
57 | |||
58 | // TODO: add examples? | ||
45 | QString keyword; | 59 | QString keyword; |
46 | QString help; | 60 | QString help; |
61 | QVector<Argument> arguments; | ||
62 | QMap<QString, ParameterOptions> parameters; | ||
63 | QMap<QString, QString> flags; | ||
47 | Interactivity interactivity; | 64 | Interactivity interactivity; |
48 | 65 | ||
66 | void addPositionalArgument(const Argument &); | ||
67 | void addParameter(const QString &name, const ParameterOptions &options); | ||
68 | void addFlag(const QString &name, const QString &help); | ||
69 | |||
70 | QString usage() const; | ||
71 | |||
49 | /** | 72 | /** |
50 | * This function will be called to execute the command. | 73 | * This function will be called to execute the command. |
51 | * | 74 | * |