Skip to content

openpeeps/kapsis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

kapsis framework
Kapsis β€” Build delightful command line interfaces with Nim language πŸ‘‘

nimble install kapsis

kapsis Example

API reference

Github Actions Github Actions

😍 Key Features

  • Generates Commands & Subcommands based on Nim's Macros
  • CLI flat file Database JSON, MessagePack, LMDB or SQLite
  • Plugins. Extend your CLI functionality
  • Self Updater
  • Auto-Generates Bash/ZSH Completion scripts
  • Variants using tuple syntax (git|svn)
  • Short/Long Flags -r, --run
  • Colors, many colors 🌈
  • ASCII & Gradientful Preloaders ⏳
  • Prompters as Input, Dropdown, Secret, Checkbox, Radio
  • Fullscreen Sessions 🌌
  • Keyboard Events βŒ₯
  • Tables and Alignments πŸ—‚
  • UX - Highlight command for invalid inputs 🧐
  • UX - Extra comments per command using -h
  • Written in Nim language πŸ‘‘
  • Open Source | MIT License

Example

Compile with -d:debugcli to show generated commands at compile-time

import kapsis
import ./commands/[newCommand, helloCommand, helloWorldCommand]

App:
  about:
    # Optional. When not provided will use .nimble info
    "πŸ‘‹ Yay! My command line interface"

  commands:
    --- "Main commands" # separator
    $ "new" ("app", "rest"):
      ?       "Create a new project"            # describe your command
      ? app   "Create a new WEB project"        # describe a specific argument
      ? rest  "Create a new REST API project"
    
    --- "Dev stuff" # separator with text
    $ "hello" `input` ["jazz"]:
      ? "A second command"
    $ "hello.world":
      ? "A sub command"

Once compiled run myapp -h to print:

πŸ‘‹ Yay! My command line interface

Main commands:
  new app|rest                  Create a new project

Dev stuff:
  hello <input> --jazz          A second command
  hello.world                   A sub command

Append a command with -h to show all flags/arguments, including description, for example

myapp new -h

Note: -h/--help and -v/--version are built-in flags (version is extracted from .nimble file)

Imports & Callbacks

Each registered command requires an import statement.

If you add a new command called new, first you will need to import your command, which in this case should be named newCommand.nim.

This is your newCommand.nim

import kapsis/runtime

proc runCommand*(v: Values) =
  # my stuff

TODO

Do the do. Add more examples

❀ Contributions & Support

🎩 License

kapsis | MIT license. Made by Humans from OpenPeeps.
Copyright Β© 2023 OpenPeeps & Contributors β€” All rights reserved.