Coder Social home page Coder Social logo

airsequel / oclis Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 180 KB

The obvious CLI specification format. You define the spec, Oclis generates the code! Support for PureScript so far. PRs for more languages appreciated!

License: ISC License

Makefile 4.59% Nix 9.82% NCL 26.33% Rust 59.26%
cli cli-spec docopt nickel polyglot specification elm haskell purescript rust

oclis's Introduction

Oclis

CLI (Command Line Interface) app builder based on a simple, obvious specification file.

Motivation

Building a CLI application is a repetitive task. The same code is written over and over again. But fear not, Oclis is here to help you out!

Usage

  1. cargo install oclis
  2. oclis init - Creates an oclis.ncl specifcation file.
  3. Adapt the specification file to your liking.
    (Check out the examples directory for inspiration.)
  4. Run oclis build to generate the CLI parsing code
    (It automatically detects the main repo language, but only PureScript is supported at the moment.)
  5. Add missing dependencies to your project.
    (E.g. for PureScript check out the spago.yaml file.)
  6. Define the handler functions for your commands.
    (Check out the main function of Transity for an example.)
  7. Commit the generated code to the repository.

How It Works

Processing Pipeline of the Generated CLI App

Processing Pipeline

Unsupported CLI designs

Some features of other CLI frameworks are deliberately not supported:

  • Specifying a flag several times. (e.g. tar -v -v -v) This is error prone as it's easy to accidentally add it several times. Use a numerical verbosity flag instead (e.g. tar -v=3) or define your own counting system (e.g. tar -v=xxx)
  • Specifying flags/options after the arguments. (e.g. pandoc in.md --output=out.pdf) Disallowing this helps to prevent errors from accidentally providing an argument which is understood as a flag/option. Suggested alternatives:
    • Sub-command: pandoc convert in.md out.pdf
    • Option first: pandoc --output=out.pdf in.md
    • Extra option: pandoc --input=in.md --output=out.pdf

Related

Other CLI Builders

  • CLI Definition Language - DSL for defining command line interfaces of C++ programs.
  • Decli - Declarative CLI tool builder.
  • docopt - Command-line interface description language.
  • make-cli - Declarative CLI framework for Node.js.

Manual CLI Frameworks

Check out the repo awesome-cli-frameworks for a full overview.

Specifications

Generate GUIs From CLI

  • Claui - A GUI generator for clap using egui.
  • Gooey - Turn CLI programs into a full GUI application.
  • Klask - Automatically create GUI applications from clap apps.

Generate GUIs From Simple Code

  • Sparkle - Infer user interfaces from type signatures.
  • Streamlit - Turns data scripts into shareable web apps.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.