Skip to content

quite4work/make_cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Highly experimental CLI builder

Example

Adding CLI to ./app.ts:

#!/usr/bin/env deno run --unstable -A

import "https://deno.land/x/[email protected]/mod.ts";

export function echo(option, longOption) {
  // @echo         Prints options to console
  // --option      Option description
  // --long-option Long option description
  console.log({ option, longOption });
}

Output of ./app.ts echo --help:

app.ts echo

Prints options to console

Options:
  --option       Option description
  --long-option  Long option description

Implementaion details

Commands are created from all exported functions of Deno.mainModule.
Options are parsed from the function signature.
Descriptions are parsed from comments inside the function.
ES2018 guarantees that comments inside of a function are always preserved.

About

Highly experimental CLI builder

Resources

License

Stars

Watchers

Forks

Packages

No packages published