{"action":"created","issue":{"url":"https://api.github.com/repos/remkop/picocli/issues/687","repository_url":"https://api.github.com/repos/remkop/picocli","labels_url":"https://api.github.com/repos/remkop/picocli/issues/687/labels{/name}","comments_url":"https://api.github.com/repos/remkop/picocli/issues/687/comments","events_url":"https://api.github.com/repos/remkop/picocli/issues/687/events","html_url":"https://github.com/remkop/picocli/issues/687","id":442251458,"node_id":"MDU6SXNzdWU0NDIyNTE0NTg=","number":687,"title":"Beginner question: How to call top command and sub command","user":{"login":"duracotton","id":25416153,"node_id":"MDQ6VXNlcjI1NDE2MTUz","avatar_url":"https://avatars0.githubusercontent.com/u/25416153?v=4","gravatar_id":"","url":"https://api.github.com/users/duracotton","html_url":"https://github.com/duracotton","followers_url":"https://api.github.com/users/duracotton/followers","following_url":"https://api.github.com/users/duracotton/following{/other_user}","gists_url":"https://api.github.com/users/duracotton/gists{/gist_id}","starred_url":"https://api.github.com/users/duracotton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duracotton/subscriptions","organizations_url":"https://api.github.com/users/duracotton/orgs","repos_url":"https://api.github.com/users/duracotton/repos","events_url":"https://api.github.com/users/duracotton/events{/privacy}","received_events_url":"https://api.github.com/users/duracotton/received_events","type":"User","site_admin":false},"labels":[{"id":530113807,"node_id":"MDU6TGFiZWw1MzAxMTM4MDc=","url":"https://api.github.com/repos/remkop/picocli/labels/question","name":"question","color":"cc317c","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2019-05-09T13:57:41Z","updated_at":"2019-05-10T10:23:00Z","closed_at":null,"author_association":"NONE","body":"Hi,\r\n\r\nI have an application which requires a base set of input parameters.\r\nI have two use cases which require all of these parameters but each of them also a different input parameter on top.\r\n\r\nSo I thought it would be the best to call the top-level command with the base set of input parameters plus the sub command method which processes the corresponding use case then with one call to the application.\r\n\r\nI read the following chapters: https://picocli.info/#_subcommand_methods and https://picocli.info/#_convenience_methods_for_subcommands\r\n\r\nSo it should be something like this I guess - similiar to what is shown in the first link of the documentation (chapter 18.2.1):\r\n\r\n```\r\n@Command(\r\n\t\tname = \"rla\",\r\n\t\tmixinStandardHelpOptions = true\r\n\t\t)\r\npublic class App{\r\n\r\n\t@Option(names = {\"-bb\"}, required = true)\r\n\tprivate String bb;\r\n\t//think of several required variables here\r\n\t\r\n\tpublic static void main(String[] args) {          \r\n    \tCommandLine cl =  new CommandLine(App.getInstance());\r\n    \tcl.parseWithHandler(new RunAll(), args);\t//convencience method as suggested in documentation chapter 18.4. \r\n    }\r\n    \r\n    @Command\r\n    public void usecase1(@Option(names = {\"-uc1p\"}) String abc) {\r\n    \tSystem.out.println(\"\\n\\n Usecase 1\" + abc + \"\\n\\n\");\r\n    }\r\n    \r\n    @Command\r\n    public void usecase2(@Option(names = {\"-uc2p\"}) String abc) {\r\n    \tSystem.out.println(\"\\n\\n Usecase 2\" + abc + \"\\n\\n\");\r\n    }\r\n\t\r\n}\r\n```\r\n\r\nResults:\r\n_With calling the top command_\r\njava -jar \"rla.jar\" rla -bb \"z\" usecase1 -uc1p \"a\":\r\n\r\n> Unmatched argument: rla\r\n> Usage:\r\n> \r\n> \r\n> rla [-hV] [-bb=<bb>] [COMMAND]\r\n> \r\n> Description:\r\n> \r\n> XXXX\r\n> \r\n> Options:\r\n>       -bb=<bb>\r\n>   -h, --help      Show this help message and exit.\r\n>   -V, --version   Print version information and exit.\r\n> Commands:\r\n>   usecase1\r\n>   usecase2\r\n\r\n_Or only calling the subcommand:_\r\njava -jar \"rla.jar\" usecase1 -uc1p \"a\":\r\n> Exception in thread \"main\" java.lang.reflect.InvocationTargetException\r\n>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n>         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)\r\n>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)\r\n>         at java.lang.reflect.Method.invoke(Unknown Source)\r\n>         at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:61)\r\n> Caused by: picocli.CommandLine$ExecutionException: Parsed command (com.XXXXXXXXXX.App@4802796d) is not Method, Runnable or Callable\r\n>         at picocli.CommandLine.execute(CommandLine.java:1213)\r\n>         at picocli.CommandLine.access$800(CommandLine.java:141)\r\n>         at picocli.CommandLine$RunAll.handle(CommandLine.java:1413)\r\n>         at picocli.CommandLine$RunAll.handle(CommandLine.java:1376)\r\n>         at picocli.CommandLine$AbstractParseResultHandler.handleParseResult(Comm\r\n> andLine.java:1243)\r\n>         at picocli.CommandLine.parseWithHandlers(CommandLine.java:1526)\r\n>         at picocli.CommandLine.parseWithHandler(CommandLine.java:1465)\r\n>         at com.XXXXXXXXXX.App.main(App.java:112)\r\n>         ... 5 more\r\n\r\n\r\nHow do I call the app correctly :D?"},"comment":{"url":"https://api.github.com/repos/remkop/picocli/issues/comments/491240179","html_url":"https://github.com/remkop/picocli/issues/687#issuecomment-491240179","issue_url":"https://api.github.com/repos/remkop/picocli/issues/687","id":491240179,"node_id":"MDEyOklzc3VlQ29tbWVudDQ5MTI0MDE3OQ==","user":{"login":"remkop","id":5917763,"node_id":"MDQ6VXNlcjU5MTc3NjM=","avatar_url":"https://avatars2.githubusercontent.com/u/5917763?v=4","gravatar_id":"","url":"https://api.github.com/users/remkop","html_url":"https://github.com/remkop","followers_url":"https://api.github.com/users/remkop/followers","following_url":"https://api.github.com/users/remkop/following{/other_user}","gists_url":"https://api.github.com/users/remkop/gists{/gist_id}","starred_url":"https://api.github.com/users/remkop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/remkop/subscriptions","organizations_url":"https://api.github.com/users/remkop/orgs","repos_url":"https://api.github.com/users/remkop/repos","events_url":"https://api.github.com/users/remkop/events{/privacy}","received_events_url":"https://api.github.com/users/remkop/received_events","type":"User","site_admin":false},"created_at":"2019-05-10T10:23:00Z","updated_at":"2019-05-10T10:23:00Z","author_association":"OWNER","body":"I think what you are looking for is `RunLast` instead of `RunAll`.\r\nThis is the default and is what most applications use."}}
{"actor":{"display_login":"remkop"}}