A simple command argument manipulator
VimL Shell
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.ci
autoload/vital/__vital__
doc/Vital
test
.gitignore
.travis.yml
.vintrc.yaml
LICENSE.md
README.md
appveyor.yml

README.md

vital-Argument

Travis CI AppVeyor Version 0.1.0 Support Vim 7.4.2137 or above Support Neovim 0.1.7 or above MIT License Doc

Vital.Argument is a simple library to manipulate a command argument. It provides several fundamental methods only and developer need to parse argument by them self like:

let s:Argument = vital#vital#import('Argument')

function! s:command_cat(qargs) abort
  let args = s:Argument.new(a:qargs)

  " NOTE: args.params is initialized to an empty dictionary
  let args.params.show_all = args.get('-A|--show-all')
  let args.params.number_nonblock = args.get('-b|--number-nonblank')
  let args.params.show_ends = args.get('-E|--show-ends')
  let args.params.number = args.get('-n|--number')
  let args.params.squeeze_blank = args.get('-s|--squeeze-blank')
  let args.params.show_tabs = args.get('-T|--show-tabs')
  let args.params.show_nonprinting = args.get('-v|--show-nonprinting')

  if args.get('-e')
    let args.params.show_ends = 1
    let args.params.show_nonprinting = 1
  endif
  if args.get('-t')
    let args.params.show_tabs = 1
    let args.params.show_nonprinting = 1
  endif

  let options.files = args.map_p(
        \ 'v:val ==# ''%'' ? expand(v:val) : v:val'
        \).list_p()

  " DO SOMETHING WITH A PARSED OPTIONS
endfunction

command! -nargs=* Cat call s:command_cat(<q-args>)

See also: