mika-f / asterisk

Asterisk is command manager for command line.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Asterisk

Asterisk is command manager for command line.

movie

Features

  • add/remove/edit new functions in the shell
  • add/remove/edit new functions as alias to existing commands
  • add/remove/edit new functions within namespace
  • conditional functions
  • pre/post hooks in commands

Installation

From Source

$ git clone https://github.com/mika-f/asterisk.git
$ cd /path/to/asterisk
$ cargo build --release

From Package Manager

$ cargo install asterisk

Basic Usage

initialize or reload asterisk:

# bash
$ eval $(ast init bash)

# zsh
$ eval $(ast init zsh)

# fish
$ ast init fish | source

# PowerShell
$ ast init pwsh | Invoke-Expression

add a new function to asterisk:

# interactive
$ ast add

# command line
$ ast add \
  --command "rg" \
  --name search \
  --description "search expression with ripgrep

remove a function from asterisk:

$ ast remove search

execute command with asterisk:

# pass-through
$ ast exec search

# direct
$ search

Advanced Usage

Command Alias

if you want to add a subcommands to existing commands:

# add `clear` sub-command to git
$ ast add --wrap git --name clear --command ...

# and reload asterisk
$ exec -l $SHELL

# execute with sub-command
$ git clear

Namespace

if you want to add a subcommands into a new/existing namespace:

# add `jpy` sub-command into `ether` namespace
$ ast add --wrap ether --name jpy --command ...

# and reload asterisk
$ exec -l $SHELL

# execute with sub-command
$ ether jpy

Command-Line Named Arguments

if you want to provide some arguments to functions:

# add `currency` arg into sub-command of `coin` namespace
$ ast add --wrap coin --name pair \
  --command 'curl -H "X-CMC_PRO_API_KEY: XXX" -s "https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest?slug=${currency}&convert=${fiat}" | jq "[.data][][].quote.${fiat}.price"'

# reload asterisk
$ exec -l $SHELL

# execute with args
$ coin pair --fiat=JPY --currency=ethereum

Interactive Execution

if you want to execute some functions in interactive shell, please use ast init fish --interactive for initialization.
this initialize command shows interactive gui when executing asterisk commands. for example, coin pair commands in above is execute as:

$ coin pair

and input arguments in interactive gui.
if you want to enable interactive mode partially, use --use-interactive option in register functions.

$ ast add --wrap coin --name pair --command ... --use-interactive

License

This project is licensed under either of

at your opinion.

About

Asterisk is command manager for command line.

License:Apache License 2.0


Languages

Language:Rust 100.0%