# The Command Line Starting an experiment always involves the same questions: which settings file, where the runs go, a new run or the continuation of a stopped one, a trial without instruments. `ExperimentCLI` (from `plesty.lib.experiment`) answers them the same way for every experiment, so each experiment only supplies what is its own: which devices it uses, and how it is built. ## A minimal command line ```python # power_scan.py import sys from plesty.lib.device.composite_device import CompositeDevice from plesty.lib.experiment import ExperimentCLI, Manifest cli = ExperimentCLI(Manifest(module="power_scan", title="Power scan")) @cli.rig def rig(args, config, skip): return CompositeDevice(["pm"]) @cli.build def build(args, config, run_root, devices): return PowerScan(config, devices=devices, run_root=run_root) if __name__ == "__main__": sys.exit(cli.main()) ``` `PowerScan` is the experiment class from [Write the scan](../quickstart/experiment.md#write-the-scan). The two functions are required: - **`@cli.rig`** builds the devices the experiment uses (PLESTY calls them its **rig**). It receives the parsed command-line arguments (`args`), the settings (`config`), and `skip`, the names of optional devices the operator chose to go without (see [Checking the Devices Before a Run](checking_devices.md)). It is called again each time the operator retries after a device failed to answer. Return `None` for an experiment that uses no devices. - **`@cli.build`** builds the experiment. It receives `args`, `config`, the folder to save runs in (`run_root`) and the devices; `devices` is `None` in a dry run, where nothing is connected. ## Options | Option | Does | |---|---| | `-c FILE`, `--config FILE` | read the settings from `FILE` instead of the default, `config/default.yaml` (see [The run configuration: `config/*.yaml`](../common/yaml_config.md#the-run-configuration-configyaml)) | | `--run-root FOLDER` | save the run in `FOLDER` instead of the default | | `-r RUN_ID`, `--resume RUN_ID` | continue a stopped run (see [Stopping and Continuing a Run](stopping.md)) | | `--run-id NAME` | name the new run `NAME` instead of `_-