NASA-AMMOS / aerie-cli

An unofficial CLI for interacting with Aerie planning software
MIT License
3 stars 4 forks source link

Global Command-Line Options #36

Closed cartermak closed 1 year ago

cartermak commented 1 year ago

Ticket to investigate whether Typer gives us a way to define a command-line arg that applies to all commands in an app. Possible use cases:

Navarro-Jonathan commented 1 year ago

One solution is to use typer's app.callback, which allows us to receive additional command-line args. We can use this to write the arguments to a global variable.

Typer also provides a context that can be supplied to commands, but that would require passing the context to every command to work globally.

One issue with the current method is that the additional options can only be passed after aerie-cli. The options cannot come after commands. For example, aerie-cli --v plans list will be accepted. However, aerie-cli plans list --v will be rejected. This can be written in the documentation in order to avoid any confusion.

For an example of this solution in practice, see: 6216bb5