Skip to main content

No project description provided

Project description


Clifier is a simple, tiny script to generate Argparse commands and subparsers from yaml config file.

All arguments and parameters names same like in Argparser module, so you do not need to know new lexic.

Whan you use clifier you don't need to create separate documentation for your users - you can just use config.yaml file as doc.


To install clifier - use pip:

pip install clifier 


In folder clifier/examples you can find the example cli with config file. Just copy it to you local env and test.

Simple example of yaml config:

  prog: 'Clifier Example'
  description: Example for Clifier

   - keys: ['-v', '--version']
     help: "show Clifier Example version"
     action: show_version()
     default: True

    - keys: ['game']
      help: Write a name of the gave, what you want to play

    - keys: ['-c', '--count']
      help: Put number how much times you want to play
      default: 2

    - keys: ['-t', '--time']
      help: Put how much second you want to sleep

Sections in config file

"parser" section

Used to define args equal to args of argparse.ArgumentParser() init method, for example:

- prog
- description
- usage
- epilog and etc 

to know more, look at official Argparse documentation:

"commands" section

commands properties equal to add_argument method 

"subparsers" section

name of subparser section element - it's a name, what equals to 
add_parser() argument "name" of object what returned by 

it's a Subparser name and it's not showed as argument in parser

To use Clifier in your code

Prepare variable with path to your config file with cli:

config_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), "cli.yaml")

Initialise clifier

cli = clifier.Clifier(config_path, prog_version="0.0.1")

And get parser like standart Argparse parser

parser = cli.create_parser()
args = parser.parse_args()

That's it!

Adding custom actions

You can add to Clifier Custom Argparser Actions with method add_actions():

cli = clifier.Clifier(config_path)
cli.add_actions((your_custom_action_1, your_custom_action_2)

To use those actions in Cli, define them in command line config file with "action" property, for example:

Custom actions defined from box in Clifier


method to create command -v, --version to show program version for usage:

1. provide arg prog_version to Clifier() or define "version" param in config

    example in config.yaml:

       prog: 'your prog name'
       version: "0.0.1"


    cli = clifier.Clifier(config_path, prog_version="0.0.1")

2. define -v, --version command in cli config:

       - keys: ['-v', '--version']
         help: "show Clifier Example version"
         action: show_version()
         default: True

This action check exist or not file_path that was provided by user to command line.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for clifier, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size clifier-0.0.1-py2.py3-none-any.whl (6.3 kB) File type Wheel Python version py2.py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page