Replies: 2 comments
-
Sure. CommandLineParser.parseAndRun(myCliktApp, argv) { /* this is empty instead of calling it.run() */ } There are also other ways to test your code that you might want instead. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thank you this works like a charm! The testing docs in part convinced me that Clikt will worth using in this project, but my test setup turned out to be a bit more convoluted than standard user-cases :) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a project that uses Clikt for command line parsing, but I also want to use it as a library. In the latter case I don't want the main entry point of my program to be executed, but I want to expose API's (called by my entry point when used from the cmdline) for my caller. It'd make sense to me to also use Clikt to configure my class instance, but when implementing tests I found that
parse()
implicitly invokesrun()
, messing up the state of my object (I'm using iterators internally...):The only workaround I found is to introduce an extra ("-A - You are an API now") option, that makes
run()
exit early. I still wonder if there's a way to configure the object (set its members) via Clikt, without invokingrun()
?Beta Was this translation helpful? Give feedback.
All reactions