Closed machaval closed 1 year ago
I would definitely prefer this new experience. CLI apps are on the rise and the majority of great CLI tools follow this approach. Having dw
in like that will just make it a consistent and simplified experience for CLI-users.
May I suggest to use a custom renderer in Picocli and group the subcommand display. For example, all spell related sub-commands go under "Spells" section.
Also, maybe adding a version
command is a good idea.
A good read about CLI apps - https://medium.com/@jdxcode/12-factor-cli-apps-dd3c227a0e46
I agree with @manikmagar on the spells. There still seems to be many related commands to them, could they be put under a general spell
command that has create, exec, list, update and wizard options?
I agree with @manikmagar on the spells. There still seems to be many related commands to them, could they be put under a general
spell
command that has create, exec, list, update and wizard options?
There is a way to create nested subcommands with the possibility of grouped helped display with Picocli.
Should from-dw1
be just migrate
? --> dw migrate <dw1.dwl>
. Unless plan to support other migrations, which can add optional params dw migration --source dw1 dw1.dwl
.
P.S: CLIs are my fav topic :). Something I enjoyed reading previously - https://clig.dev/
This is the new interface
____ __ ____ __ _ _ ____ __ _ _ ____
( \ / _\(_ _)/ _\ / )( \( __) / _\ / )( \( __)
) D (/ \ )( / \\ /\ / ) _) / \\ \/ / ) _)
(____/\_/\_/(__)\_/\_/(_/\_)(____)\_/\_/ \__/ (____)
Usage: <main class> [-hV] [COMMAND]
-h, --help Show this help message and exit.
-V, --version Print version information and exit.
Commands:
run Runs provided DW script.
add-wizard Adds a new Wizard to your network of trusted wizards.
migrate Translates a DW1 script into a DW2 script.
spell Runs the specified Spell.
help Display help information about the specified command.
repl Starts the DW repl.
Example:
dw run -i payload <fullPathToUser.json> "output application/json --- payload
filter (item) -> item.age > 17"
Documentation reference:
https://docs.mulesoft.com/dataweave/latest/
@manikmagar @afelisatti
For spells there are sub commands
Usage: <main class> spell [-lsv] [--eval] [--untrusted]
[--language-level=<languageLevel>] [-o=<output>]
[--spell-home=<spellHome>] [-i=<Name=File>]...
[-p=<String=String>]... [--privileges=<privileges>[,
<privileges>...]]... [SPELL-ID] [COMMAND]
Runs the specified Spell.
[SPELL-ID] The name of the Spell to be created. For example
`playground`
--eval Executes the script but it doesn't use the writer.
This is useful when launching a webserver.
-i, --input=<Name=File> Declares a new input.
-l, --local Will look for the spell in the current directory.
--language-level=<languageLevel>
The version of DW to be supported.
-o, --output=<output> Specifies output file for the transformation if not
standard output will be used.
-p, --param=<String=String>
Parameter to be passed. All input parameters are
accessible through the variable `params` of type
object.
--privileges=<privileges>[,<privileges>...]
A list of all allowed runtime privileges for this
execution to have.
-s, --silent Run in silent mode it reduces the logging on the
standard output.
--spell-home=<spellHome>
Home folder where to search local spells.
--untrusted Run the script as untrusted, which means that the
script has no privileges.
-v, --verbose Run the script as untrusted, which means that the
script has no privileges.
Commands:
create Creates a new spell with the given name.
list List all available spells.
update Update all spells to the latest one.
Looks good. If you use CommandLine.IHelpSectionRenderer
customization, the main help section could include spells. Here is an example of changes - https://github.com/mulesoft-labs/data-weave-cli/pull/73
____ __ ____ __ _ _ ____ __ _ _ ____
( \ / _\(_ _)/ _\ / )( \( __) / _\ / )( \( __)
) D (/ \ )( / \\ /\ / ) _) / \\ \/ / ) _)
(____/\_/\_/(__)\_/\_/(_/\_)(____)\_/\_/ \__/ (____)
Usage: <main class> [-hV] [COMMAND]
-h, --help Show this help message and exit.
-V, --version Print version information and exit.
Commands:
run Runs provided DW script.
add-wizard Adds a new Wizard to your network of trusted wizards.
migrate Translates a DW1 script into a DW2 script.
spell Runs the specified Spell.
create Creates a new spell with the given name.
list List all available spells.
update Update all spells to the latest one.
help Display help information about the specified command.
repl Starts the DW repl.
Example:
dw run -i payload <fullPathToUser.json> "output application/json --- payload
filter (item) -> item.age > 17"
Documentation reference:
https://docs.mulesoft.com/dataweave/latest/
This pr propose a new CLI interface more similar to
git
. Why? The command line has been growing and the amount of parameters that triggers different things makes it very hard to understand what works with what.So taking inspiration from git we are using sub commands approach and flags will be activated by each sub command.
This will be the new set of sub commands including a new very basic REPL