Konubinix' opinionated web of thoughts

Clk Bash Customcommand

Fleeting

clk bash customcommand

To take advantage of all the power of clk, we heartily recommend you use python customcommand.

If by any chance you still find the need to write a bash script instead of a python command, we provide this feature as well.

Simply create the command with the following line:

clk customcommand create bash somecommand

Your editor should then be opened to write the content of the shell script.

You can add the code at the end of the script. Don’t modify the beginning as it is used for clk to parse the help output of the command.

For instance, imagine you want to make some text be told by a cow.

First, install cowsay.

python3 -m pip install cowsay

Then, indicate that the code accepts an argument using the clk basic bash argument format.

clk_usage () {
    cat<<EOF
$0

Make a cow say something
--
A:content:str:Content to say
EOF
}

Then, use that argument to let a cow say it.

cowsay "${CLK___CONTENT}"

Then try the new command.

clk somecommand --help
Usage: clk somecommand [OPTIONS] CONTENT

  Make a cow say something

  The current parameters set for this command are: --help

Arguments:
  CONTENT  Content to say

Options:
  --help-all  Show the full help message, automatic options included.
  --help      Show this message and exit.
clk somecommand "Hello!"
  ______
| Hello! |
  ======
      \
       \
         ^__^
         (oo)\_______
         (__)\       )\/\
             ||----w |
             ||     ||

Notes linking here