Skip to content

TimoKats/cly

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⛩️ cly

Go Report Card License: GPL v3 GitHub tag

Cly allows you to create feature rich aliases in YAML. The example below is an example YAML showcasing 5 aliases with different configuration options. You can add this file in ~/.cly.yaml or somewhere custom by setting the env CLYPATH.

update:
  command: /some/path/script.sh $@  # adds args to alias. E.g.: cly run update <x> <y>
  subcommands:
  - name: ping  # subcommand for alias, called with: cly run update <ping>
    command: /some/path/script.sh

dashboard:
  command: streamlit run main.py
  dir: /path/to/python/  # sets a directory to run an alias in

python:               # Insert args based on index. E.g.: cly run test <python3.12>
  command: $0 test.py # Runs <python3.12> main.py

create-file:
  concurrent: true  # Runs the commands below concurrently
  commands:
  - touch $0
  - echo hi > $0

hi:
  command: python3 test/env.py
  envs:
  - name: AWS_REGION # adds environment variables
    value: us-east-1
  - name: CITY
    value: Rotterdam

Docs

Cly has two commands: run <<command>> and ls. You can install cly using: go install github.com/TimoKats/cly@latest. The table shows an overview of the fields that can be supplied in your YAML alias objects to configure cly.

Field Description
command/commands The alias command. Can be a list of commands or one command.
name Name of the alias. Mandatory for subcommands. Root commands derive the name from the YAML name (see above).
dir Directory to run the alias in. If empty, current working directory.
envs Add additional env variables for the alias. List of name/value pairs.
concurrent Boolean. If true (and multiple commands are supplied), then the commands are executed in concurrent threads.
subcommands List of command objects (i.e. all other fields apply) that become subcommands. E.g. cly run *command* *subcommand*

 

Finally, you can pass parameters to your aliases when invoking them. For this, we use bash syntax. Adding $@ adds all parameters to an alias. $0...n inserts an alias based on the index. The example above has some examples for this.