cli

Command-line tools.

digraph InheritanceGraph { graph [bgcolor=transparent, color=lightsteelblue2, fontname=Arial, fontsize=10, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, splines=spline, style="dashed, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=10, height=0, penwidth=2, shape=box, style="filled, rounded", width=0]; edge [color=lightslategrey, penwidth=1]; subgraph cluster_abc { graph [label=abc]; node [color=1]; "abc.ABC" [URL="https://docs.python.org/3.6/library/abc.html#abc.ABC", label=ABC, target=_top]; } subgraph "cluster_abjad.cli" { graph [label="abjad.cli"]; node [color=2]; "abjad.cli.AbjDevScript" [URL="../api/abjad/cli.html#abjad.cli.AbjDevScript", color=black, fontcolor=white, label="Abj\nDev\nScript", target=_top]; "abjad.cli.CleanScript" [URL="../api/abjad/cli.html#abjad.cli.CleanScript", color=black, fontcolor=white, label="Clean\nScript", target=_top]; "abjad.cli.ReplaceScript" [URL="../api/abjad/cli.html#abjad.cli.ReplaceScript", color=black, fontcolor=white, label="Replace\nScript", target=_top]; "abjad.cli.StatsScript" [URL="../api/abjad/cli.html#abjad.cli.StatsScript", color=black, fontcolor=white, label="Stats\nScript", target=_top]; } subgraph cluster_builtins { graph [label=builtins]; node [color=3]; "builtins.object" [URL="https://docs.python.org/3.6/library/functions.html#object", label=object, target=_top]; } subgraph "cluster_uqbar.cli" { graph [label="uqbar.cli"]; node [color=4]; "uqbar.cli.CLI.CLI" [label=CLI, shape=oval, style=bold]; "uqbar.cli.CLIAggregator.CLIAggregator" [label=CLIAggregator, shape=oval, style=bold]; "uqbar.cli.CLI.CLI" -> "uqbar.cli.CLIAggregator.CLIAggregator"; } "abc.ABC" -> "uqbar.cli.CLI.CLI"; "builtins.object" -> "abc.ABC"; "uqbar.cli.CLI.CLI" -> "abjad.cli.CleanScript"; "uqbar.cli.CLI.CLI" -> "abjad.cli.ReplaceScript"; "uqbar.cli.CLI.CLI" -> "abjad.cli.StatsScript"; "uqbar.cli.CLIAggregator.CLIAggregator" -> "abjad.cli.AbjDevScript"; }


Classes

AbjDevScript Entry-point to the Abjad developer scripts catalog.
CleanScript Removes .pyc, *.swp files and __pycache__ and tmp directories recursively in a path.
ReplaceScript Replaces text in files recursively.
StatsScript Builds statistics about a codebase.
class abjad.cli.AbjDevScript

Entry-point to the Abjad developer scripts catalog.

Can be accessed on the commandline via abj-dev or ajv:

abjad$ ajv --help
usage: abj-dev-script [-h] [--version]
                      {help,list,book,builds,clean,material,replace,score,segment,stats}
                      ...

Entry-point to Abjad developer scripts catalog.

optional arguments:
  -h, --help            show this help message and exit
  --version             show program's version number and exit

subcommands:
  {help,list,book,builds,clean,material,replace,score,segment,stats}
    help                print subcommand help
    list                list subcommands
    book                Preprocess LaTeX files with Abjad.
    builds              Manage score package build targets.
    clean               Clean *.pyc, *.swp, .cache, __pycache__ and tmp* files
                        and folders from PATH.
    material            Manage score package materials.
    replace             Replace text.
    score               Manage score packages.
    segment             Manage score package segments.
    stats               Build statistics about Python modules in PATH.

ajv supports subcommands similar to svn:

abjad$ ajv api --help

usage: abj-dev-script [-h] [--version]
                      {help,list,book,builds,clean,material,replace,score,segment,stats}
                      ...
abj-dev-script: error: argument subparser_name: invalid choice: 'api' (choose from 'help', 'list', 'book', 'builds', 'clean', 'material', 'replace', 'score', 'segment', 'stats')

Attributes Summary

cli_classes Lists CLI classes for aggregation.
config_name
short_description

Special methods

(CLIAggregator).__call__(arguments=None)

Calls developer script.

Returns none.


Read-only properties

(CLI).argument_parser

The script’s instance of argparse.ArgumentParser.

(CLIAggregator).cli_aliases

Developer script aliases.

cli_classes

Lists CLI classes for aggregation.

(CLIAggregator).cli_program_names

Developer script program names.

(CLI).formatted_help

Formatted help of developer script.

(CLI).formatted_usage

Formatted usage of developer script.

(CLI).formatted_version

Formatted version of developer script.

(CLI).program_name

The name of the script, callable from the command line.

class abjad.cli.CleanScript

Removes .pyc, *.swp files and __pycache__ and tmp directories recursively in a path.

abjad$ ajv clean --help
usage: clean-script [-h] [--version] [--cache] [--pyc] [--pycache] [--swp]
                    [--tmp]
                    [path]

Clean *.pyc, *.swp, .cache,  __pycache__ and tmp* files and folders from PATH.

positional arguments:
  path        directory tree to be recursed over

optional arguments:
  -h, --help  show this help message and exit
  --version   show program's version number and exit
  --cache     delete *.cache folders
  --pyc       delete *.pyc files
  --pycache   delete __pycache__ folders
  --swp       delete Vim *.swp file
  --tmp       delete tmp* folders

Attributes Summary

alias
config_name
short_description

Special methods

(CLI).__call__(arguments=None)

Calls developer script.

Returns none.

Return type:None

Read-only properties

(CLI).argument_parser

The script’s instance of argparse.ArgumentParser.

(CLI).formatted_help

Formatted help of developer script.

(CLI).formatted_usage

Formatted usage of developer script.

(CLI).formatted_version

Formatted version of developer script.

(CLI).program_name

The name of the script, callable from the command line.

class abjad.cli.ReplaceScript

Replaces text in files recursively.

abjad$ ajv replace text --help
usage: replace-script [-h] [--version] [--verbose] [-Y] [-R] [-W] [-F PATTERN]
                      [-D PATTERN]
                      [path] old new

Replace text.

positional arguments:
  path                  directory tree to be recursed over
  old                   old text
  new                   new text

optional arguments:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
  --verbose             print replacement info even when --force flag is set.
  -Y, --force           force "yes" to every replacement
  -R, --regex           treat "old" as a regular expression
  -W, --whole-words-only
                        match only whole words, similar to grep's "-w" flag
  -F PATTERN, --without-files PATTERN
                        Exclude files matching pattern(s)
  -D PATTERN, --without-dirs PATTERN
                        Exclude folders matching pattern(s)

Multiple patterns for excluding files or folders can be specified by restating the –without-files or –without-dirs commands:

abjad$ ajv replace text . foo bar -F *.txt -F *.rst -F *.htm

Attributes Summary

alias
config_name
short_description
skipped_directories Skipped directories.
skipped_files Skipped files.

Special methods

(CLI).__call__(arguments=None)

Calls developer script.

Returns none.

Return type:None

Read-only properties

(CLI).argument_parser

The script’s instance of argparse.ArgumentParser.

(CLI).formatted_help

Formatted help of developer script.

(CLI).formatted_usage

Formatted usage of developer script.

(CLI).formatted_version

Formatted version of developer script.

(CLI).program_name

The name of the script, callable from the command line.

skipped_directories

Skipped directories.

Returns list.

skipped_files

Skipped files.

Returns list.

class abjad.cli.StatsScript

Builds statistics about a codebase.

abjad$ ajv stats  --help
usage: stats-script [-h] [--version] [path]

Build statistics about Python modules in PATH.

positional arguments:
  path        directory tree to be recursed over

optional arguments:
  -h, --help  show this help message and exit
  --version   show program's version number and exit

Attributes Summary

alias
config_name
short_description

Special methods

(CLI).__call__(arguments=None)

Calls developer script.

Returns none.

Return type:None

Read-only properties

(CLI).argument_parser

The script’s instance of argparse.ArgumentParser.

(CLI).formatted_help

Formatted help of developer script.

(CLI).formatted_usage

Formatted usage of developer script.

(CLI).formatted_version

Formatted version of developer script.

(CLI).program_name

The name of the script, callable from the command line.


Functions

run_ajv Entry point for setuptools.
abjad.cli.run_ajv()

Entry point for setuptools.

One-line wrapper around AbjDevScript.