Comments (7)
Hi @sbernard31, I believe the user manual mentions this; it's not supported to "go up the hierarchy".
So, this would be supported:
C SA SA1 -opt1 \
SB1 -opt2 \
SA1 -opt1 \
SB1 -opt2
But once the parser is at the SA1/SB1
subcommand level it doesn't expect to encounter parent commands of these, only sibling commands or more deeply nested subcommands.
from picocli.
Thx for answer.
I believe the user manual mentions this; it's not supported to "go up the hierarchy".
Maybe you refer to https://picocli.info/#_repeatable_subcommands_specification
Note that it is not valid to specify a subcommand followed by its parent command
(In my case this is not the parent but this is same level as the parent)
So, this would be supported:
C SA SA1 -opt1
SB1 -opt2
SA1 -opt1
SB1 -opt2
Yep but this doesn't really match my use case.
But once the parser is at the SA1/SB1 subcommand level it doesn't expect to encounter parent commands of these, only sibling commands or more deeply nested subcommands.
Does it exist an elegant way to change the parsing ?
from picocli.
Maybe I'm wrong but current behavior lead to some strange surprising behavior where
- toplevelcmd subcmd-A subcmd-B subsubB
will work
- toplevelcmd subcmd-B subsubB subcmd-A
will not.
but from a user point of view, he just execute 2 "action" in 2 different order š¤.
Intuitively I understood that an "action" is a leaf in command graph (https://picocli.info/#_repeatable_subcommands_specification)
from picocli.
About :
Does it exist an elegant way to change the parsing ?
I tried to dig in the code to see if there is a way to change/customize/extend this behavior and unfortunately I didn't find anything.
Logic seems to be directly implemented in Interpreter
code.
Could you confirm if I'm right ? š
Hard blow for me because :
- I take several days to code my command hierarchy but finally it doesn't work. Before to go I tested with
toplevelcmd subcmd-A subcmd-B subsubB
š¬ - For now, I strictly have no idea as how I could design my CLI interface to match picocli constraint... š
from picocli.
The parsing code for repeatable subcommands is not easily customizable Iām afraid.
You may need to restructure your application somehow. One idea is to use more options and fewer sub-subcommands, but you are more familiar with your objectives.
from picocli.
You may need to restructure your application somehow. One idea is to use more options and fewer sub-subcommands, but you are more familiar with your objectives.
I can describe my use case :
I need a way configure transport layer of my application :
- choosing the kind of implementation (different possible implementation based on different library)
- selecting available protocol for this implementation
- Eventually configure it with options (option available depends of implementation/protocol).
(This is even more complicated than that but I hope this is enough to understand the issue)
So for example I hoped I could do :
java -jar myapp transport \
library1 protocol1 -protocol1option value \
protocol2 \
library2 protocol3 -protocol3option value
Using subcommand make easy:
- to attach specific option only to specific protocol/implementation,
- to add supported protocol to an implementation.
- to extend the application by just adding a new subcommand (to add protocol or implementation)
- to have discoverable documentation with split help.
from picocli.
It seems the feature was requested several time by the past :
from picocli.
Related Issues (20)
- [Question] Best way to provide custom description formatting?
- subcommandsRepeatable = true vs HelpCommand HOT 3
- expected behavior of getExecutionResult() with RunAll stategy ? HOT 2
- Use picocli without Reflection API HOT 1
- ManPageGenerator fails with Quarkus
- Setter method annotated by @Option with default value not been invoked when reusing it HOT 2
- ITypeConverter for custom generics (type constructors) HOT 4
- Configuring end-of-options position after parameter HOT 2
- How to solve the problem of garbled Chinese output HOT 6
- Contribute a change in docs HOT 2
- picocli-shell-jline3 jpms module HOT 3
- CLI library learning
- PicocliCommands.java:283: error: [Overrides] Varargs doesn't agree for overridden method
- Build is Broken HOT 3
- Failed to instantiate [java.util.List]: Specified class is an interface HOT 2
- JLine3 Signal Handling HOT 2
- Documentation unclear re. default for negatable options HOT 2
- Failed to use subcommand CommandLine to execute command HOT 2
- picocli-codegen does not generate native-image.properties HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ššš
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from picocli.