Skip to content

Instantly share code, notes, and snippets.

@tef
Last active May 3, 2018 17:18
Show Gist options
  • Save tef/777dfc4f3254e35eef3da225364d8e8e to your computer and use it in GitHub Desktop.
Save tef/777dfc4f3254e35eef3da225364d8e8e to your computer and use it in GitHub Desktop.

tab completion

a vex command can have multiple parts: vex name:subname:subsubname --args .., and the subnames are grouped, and have aliases.

grouping means that vex help prints them out in groups.

tab completing with no command shows all root commands, but not aliases:

sycamore:demo tef$ vex 
add        commit     fileprops  help       include    message    remove     session    switch     
branch     debug      forget     id         init       missing    restore    sessions   undo       
branches   diff       git:       ignore     log        redo       rewind     status     update     

changelog is an alias, and appears if matching:

sycamore:demo tef$ vex c
changelog   commit      

commit has subcommands, so the important ones are shown (not aliases)

sycamore:demo tef$ vex commit
commit           commit:append    commit:prepare   commit:replay    commit:rollback  
commit:amend     commit:apply     commit:prepared  commit:revert    commit:squash    
sycamore:demo tef$ vex commit

adding a : will show all (except aliases)

sycamore:demo tef$ vex commit:
amend      append     apply      prepare    prepared   replay     revert     rollback   squash     

subcommands

have tab completion, even for help:

$ vex help commit:a
amend    append   apply    

help text:

sycamore:demo tef$ vex help commit:append 
Name: vex commit:append -- append changes from other branch to current session

Usage: vex commit:append <branch>

usage:

sycamore:demo tef$ vex commit:append --help
Usage: vex commit:append <branch>

... and tab completion for arguments:

sycamore:demo tef$ vex commit:append 
another   latest    

... and there's a flag only way to pass arguments too, and yes, tab completion works for args too

sycamore:demo tef$ vex commit:append --branch=
another   latest    

example help

vex always uses a pager for output, like git diff, but for all commands.

the grouping of subcommands is indicated by blank lines

sycamore:demo tef$ vex help
Name: vex -- a database for files

Usage: vex [help] <init|undo|redo|status|log|diff|switch|...> [--help]

Description: vex is a command line program for saving changes to a project, switching between different versions, and sharing those changes.

vex supports bash completion: run `complete -o nospace -C vex vex`

Commands:
  init        create a new vex project
  undo        undo the last command
  redo        redo last undone command
  status      list the files being tracked by vex
  log         list changes to project
  diff        show the current changes to the project as a diff
  switch      change which directory (inside the project) is worked on

  add         add files to the project
  forget      remove files from the project, without deleting them
  remove      remove files from the project, deleting them
  restore     restore files from the project, overwriting modifications
  missing     files in current directory but not in project
  ignore      add ignored files
  include     add include files
  fileprops   get/set properties on files

  id          what was the last change
  commit      save the working copy and add an entry to the project changes
  message     edit commit message
  rewind      * rewind session to earlier change
  update      * update branch to start from new upstream head

  branch      open/create branch
  branches    list branches
  session     describe the active session for the current branch
  sessions    show all sessions for current branch

  debug       internal: run a command without capturing exceptions, or repairing errors

the help pages document the options too:

sycamore:demo tef$  vex help commit
Name: vex commit -- save the working copy and add an entry to the project changes

Usage: vex commit [--add] [<file>...]
Usage: vex [help] commit:<prepare|prepared|amend|apply|append|replay|squash|rollback|revert> [--help]

Options:
  --add Run `vex add` before commiting
  --file        Commit only a few changed files

Description: `vex commit` saves the current state of the project.

Commands:
  prepare     save current working copy to prepare for commit
  prepared    commit prepared files
  amend       replace the last commit with the current changes in the project
  apply       apply changes from other branch to current session
  append      append changes from other branch to current session
  replay      replay changes from other branch to current session
  squash      * flatten commits into one
  rollback    * take older version and re-commit it
  revert      * new commit without changes made in an old version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment