Cly enables the creation of feature-rich aliases using YAML. With cly, you can pass parameters, environment variables, run commands sequentially/concurrently, etc. All using simple YAML configuration. Goodbye bashrc!
Cly is a powerful tool that enables the creation of feature-rich command aliases using YAML configuration. By allowing the definition of complex behaviors and commands, Cly streamlines automation tasks and enhances productivity within command-line environments.
Here’s a glimpse of how to define aliases in Cly using YAML:
update:
command: /some/path/script.sh $@ # Adds arguments to alias, e.g. cly run update <x> <y>
subcommands:
- name: ping # Subcommand used as: cly run update <ping>
command: /some/path/script.sh
dashboard:
command: streamlit run main.py
dir: /path/to/python/ # Sets a specific directory for execution
python: # Use indexed arguments, e.g. cly run test <python3.12>
command: $0 test.py
create-file:
concurrent: true # Executes following commands concurrently
commands:
- touch $0
- echo hi > $0
hi:
command: python3 test/env.py
envs:
- name: AWS_REGION # Adds environmental variable
value: us-east-1
- name: CITY
value: Rotterdam
Cly operates with two primary commands: run <<command>> and ls. The setup allows for extensive customization of alias functionalities, detailed in the following table:
| Field | Description |
|---|---|
| command/commands | The primary command or a list of commands defined for the alias. |
| name | Mandatory for subcommands; derives automatically for root commands from YAML definition. |
| dir | Designates the directory in which to execute the command; defaults to the current working directory. |
| envs | Allows the addition of supplementary environment variables for the alias. |
| concurrent | A boolean indicating execution in concurrent threads for multiple commands. |
| subcommands | Defines additional commands as subcommands to the main alias command. |
Parameters for aliases can be passed during invocation, utilizing bash syntax. $@ captures all parameters, while $0...n allows inserting particular arguments based on their index.
Cly is easy to install with the command: go install github.com/TimoKats/cly@latest, and the customizable nature of this tool makes it a valuable asset for developers aiming to enhance their command-line efficiency.
No comments yet.
Sign in to be the first to comment.