click

cli apps made easy

intro

demo
questions

Intro

Click is a library for creating command line interface applications.

click in three points

  • arbitrary nesting of commands
  • automatic help page generation
  • supports lazy loading of subcommands at runtime

why click?

http://click.pocoo.org/5/why/

Click is designed to be fun to work with and at the same time not stand in your way. It’s not overly flexible either. Currently, for instance, it does not allow you to customize the help pages too much.

the goal

$ git
usage: git [--version] [--help] [-C <path>] [-c name=value]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]

The most commonly used git commands are:
   add        Add file contents to the index
   bisect     Find by binary search the change that introduced a bug
   branch     List, create, or delete branches
   checkout   Checkout a branch or paths to the working tree
   clone      Clone a repository into a new directory
   commit     Record changes to the repository
   diff       Show changes between commits, commit and working tree, etc
   fetch      Download objects and refs from another repository
   grep       Print lines matching a pattern
   init       Create an empty Git repository or reinitialize an existing one
   log        Show commit logs
   ...

DEMO

source: https://github.com/epequeno/acpg-feb2016

Questions

thanks!

Alamo City Python Group Feb 2016

click - cli apps made easy

By Estevan Pequeno

click - cli apps made easy

a brief introduction to command line applications with click

  • 777