A collection of classes and commands for automated command line scripting using Python.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

171 lines
6.2 KiB

---
title: CLI
---
The `tease` command may be used to parse a steps file, providing additional utilities for working with commands.
## Getting Help
Use `tease -h` to get started. There are three (3) sub-commands: [docs](#the-docs-sub-command), [inventory](#the-inventory-sub-command), and [script](#the-script-sub-command).
```text
usage: tease [-h] [-v] [--version] docs, inventory, script ...
positional arguments:
docs, inventory, script
Commands
docs Output documentation instead of code.
inventory (inv) Copy an inventory item to a local directory.
script Output the commands.
optional arguments:
-h, --help show this help message and exit
-v Show version number and exit.
--version Show verbose version information and exit.
NOTES
This command is used to parse configuration files and output the commands.
```
## The Docs Sub-Command
A nice benefit of using configuration for commands is that the information may be used to output documentation. This allows the automatic creation of an install guide or tutorial using exactly the same commands that would be used for the actual work.
Additionally, Script Tease provides the [explain](usage/messages.md#explain) and [screenshot](usage/messages.md#screenshot) commands that help provide extra content for documentary output.
```text
usage: tease docs [-h] [-o= {html,md,plain,rst}] [-C= VARIABLES] [-i= STEPS_FILE] [-O= OPTIONS] [-P= {centos,ubuntu}]
[-T= TEMPLATE_LOCATIONS] [-w= OUTPUT_FILE] [-V= VARIABLES_FILE] [-D] [-p]
optional arguments:
-h, --help show this help message and exit
-o= {html,md,plain,rst}, --output-format= {html,md,plain,rst}
The output format; HTML, Markdown, plain text, or ReStructuredText.
-C= VARIABLES, --context= VARIABLES
Context variables for use in pre-parsing the config and templates. In the form of: name:value
-i= STEPS_FILE, --input-file= STEPS_FILE
The path to the configuration file.
-O= OPTIONS, --option= OPTIONS
Common command options in the form of: name:value
-P= {centos,ubuntu}, --profile= {centos,ubuntu}
The OS profile to use.
-T= TEMPLATE_LOCATIONS, --template-path= TEMPLATE_LOCATIONS
The location of template files that may be used with the template command.
-w= OUTPUT_FILE, --write= OUTPUT_FILE
Write the output to disk.
-V= VARIABLES_FILE, --variables-file= VARIABLES_FILE
Load variables from a file.
-D, --debug Enable debug mode. Produces extra output.
-p Preview mode.
```
## The Inventory Sub-Command
Script Tease ships with few pre-defined configurations that may be copied to a local directory.
Use `tease inv ?` to list available inventory items.
```text
usage: tease inventory [-h] [-P= TO_PATH] [-D] [-p] name
positional arguments:
name The name of the inventory item. Use ? to list available items.
optional arguments:
-h, --help show this help message and exit
-P= TO_PATH, --path= TO_PATH
The path to where the item should be copied. Defaults to the current working directory.
-D, --debug Enable debug mode. Produces extra output.
-p Preview mode.
```
!!! note "Road Map"
A future release will include support for multiple inventory locations that may be defined by the user.
## The Script Sub-Command
The `script` sub-command exports command configuration to actual Bash statements. Minimum usage is
```bash
tease -i steps.ini
```
This will output the statements represented in the specified configuration file. There are quite a few other parameters.
```text
usage: tease script [-h] [-c] [-s] [-C= VARIABLES] [-i= STEPS_FILE] [-O= OPTIONS] [-P= {centos,ubuntu}] [-T= TEMPLATE_LOCATIONS]
[-w= OUTPUT_FILE] [-V= VARIABLES_FILE] [-D] [-p]
optional arguments:
-h, --help show this help message and exit
-c, --color Enable code highlighting for terminal output.
-s, --shebang Add the shebang to the beginning of the output.
-C= VARIABLES, --context= VARIABLES
Context variables for use in pre-parsing the config and templates. In the form of: name:value
-i= STEPS_FILE, --input-file= STEPS_FILE
The path to the configuration file.
-O= OPTIONS, --option= OPTIONS
Common command options in the form of: name:value
-P= {centos,ubuntu}, --profile= {centos,ubuntu}
The OS profile to use.
-T= TEMPLATE_LOCATIONS, --template-path= TEMPLATE_LOCATIONS
The location of template files that may be used with the template command.
-w= OUTPUT_FILE, --write= OUTPUT_FILE
Write the output to disk.
-V= VARIABLES_FILE, --variables-file= VARIABLES_FILE
Load variables from a file.
-D, --debug Enable debug mode. Produces extra output.
-p Preview mode.
```
### Context Variables May be Provided on the Command Line
To supply context variables on the command line:
```bash
tease -C domain_name:example.com -C domain_tld:example_com
```
!!! important
Variables provided on the command will always override those provided in a file.
### Loading Context Variables from a File
Context variables may be loaded from a file:
```ini
[domain_name]
value = example.com
[domain_tld]
value = example_com
```
The variables above are available as template variables in a steps file.
For example, ``{{ domain_name }}`` becomes ``example.com``.
To load the variables file, use the `-V` switch:
```bash
tease -i steps.ini -V variables.ini
```
### Setting Common Options for All Commands
Rather than include a common parameter in the configuration file, it is possible to specify a common option on the command line.
```bash
tease -O sudo:yes
```
### The Difference Between Variables and Options
Variables are used to pre-process configuration files as templates, while common options are passed to *all* command instances.