Skip to content

zph/tome-cli

Repository files navigation

tome-cli

A rewrite of sub and tome and my fork of tome but with a different internal implementation in order to support:

  1. Improved auto-completion
  2. Improved usage/help outputs
  3. Faster development
  4. Testable interfaces

Usage

# shorthand syntax via bash wrapper script
tome-cli --executable kit alias --output ~/bin/kit

# further uses of kit script have embedded values for TOME_ROOT and TOME_EXECUTABLE
kit completion fish | source
kit path to file
kit pat<TAB>

# Long form
export TOME_ROOT=examples
tome-cli exec path to file
tome-cli help path to <TAB>
tome-cli completion fish | source

# Setup tab completion
tome-cli completion fish | source
eval "$(tome-cli completion zsh)"

# See instructions for a command
tome-cli completion --help

See docs for expanded instructions

Features

  • Organize a folder of scripts into a CLI sdk
  • Any language is supported via normal script #!
  • Usage text extracted from script header if USAGE: is included in leading comments
  • Full help text extracted as lines from USAGE: to first empty line
  • Builtin alias generator allows for embedding configuration flags via tome-cli alias
  • Auto completion of:
    • subcommands (exec, help, etc)
    • root folder's folder names
    • root folder's scripts
    • root script's flags and arguments (when they satisfy the --complete and TOME_COMPLETION interface)
  • Gitignore like syntax for ignoring scripts by using a .tomeignore file at base of root folder example

Capabilities

	// The *Run functions are executed in the following order:
	//   * PersistentPreRun()
	//   * PreRun()
	//   * Run()
	//   * PostRun()
	//   * PersistentPostRun()

Non Features

  • Does not support sourcing scripts into shell environment because it adds implementation complexity for other core commands