Cleo 0.4 is now out. Commands have been largely improved and are now easier to use. Helpers have also been improved. Overall, Cleo is now more intuitive.
This version breaks the backward compatibility for the following parts:
DialogHelperhas been replaced by a more robust
ProgressHelperhas been removed and the
ProgressBarclass must be used
- When using decorators or dictionaries, the signature of the callback has changed and accepts only a
Command class has been improved, with a new way of describing it via docstring and several helper methods:
The definition of a command can now be declared in the docstring:
The logic of the command now needs to be put in the
Commands are now easier to use with new helper methods.
These methods make it easier to access command's arguments and options.
This methods writes a new line to the output:
A style can also be passed as a second argument:
The native styles have their own helper methods:
Calls another command:
If you want to suppress the output of the executed command,
you can use the
call_silent() method instead.
Confirm a question with the user.
In this case, the user will be asked “Continue with this action?”. If the user answers with y it returns True or False if they answer with n. The second argument to confirm() is the default value to return if the user doesn’t enter any valid input. If the second argument is not provided, True is assumed.
Prompt the user for input.
Prompt the user for input but hide the answer from the console.
Give the user a single choice from an list of answers.
Format input to textual table.
You can also use the
table() method to retrieve a
Creates a new progress bar.
Sets a new formatting style.
ProgressHelper has been removed and the improved
ProgressBar (or its helper method
must now be used instead:
TableHelper has been deprecated and the improved
Table (or its helper method
should now be used instead:
DialogHelper has been removed and the improved
QuestionHelper (or one of its helper methods)
must now be used instead:
Two other levels of verbosity (
-vvv) have been added.
Command description format
Commands description can now be output as json and markdown:
Decorators and dictionaries notation
When using decorators or dictionaries, the signature of the callback has changed and accepts only a
This is so that helper methods can be accessed inside code functions.
Autocompletion has also been improved, and the old
bash_completion.sh has been removed.
To activate support for autocompletion, pass a
complete keyword when initializing
Now, register completion for your application by running one of the following in a terminal,
[program] with the command you use to run your application:
By default this registers completion for the absolute path to you application,
which will work if the program is accessible on your PATH.
You can specify a program name to complete for instead using the
which is required if you're using an alias to run the program.
If you want the completion to apply automatically for all new shell sessions,
add the command to your shell's profile (eg.
- Values are now properly cast by validators
- Fixing "flag" not being set properly
- Progress bar now behaves properly (Fixes #37)
-n|--no-interactionoption behaves properly (Fixes #38 and #39)
There is a lot more you can do with Cleo, you can just give a look at the documentation: http://cleo.readthedocs.org.