GithubHelp home page GithubHelp logo

petereon / argyml Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 17 KB

argyml is a command line tool that converts CLI arguments, options and flags into a YAML for downstream parsing

License: MIT License

Haskell 78.72% Shell 9.13% Just 12.15%

argyml's Introduction

Introduction

argyml is a command line tool that converts CLI arguments, options and flags into a YAML for downstream parsing

Motivation

While there are spectacularly powerful CLI tools and shell-scripts, CLI parsing in shell itself remains a manual and error prone process. argyml aims to solve this by operating in tandem with yq to allow for more structured CLI argument parsing.

Example

get_host () {
    args=$(argyml $@)
    host=$(echo $args | yq eval '.[] | select(.key == "*host*") | .value' )
    echo $host
}
$ get_host --host 127.0.0.1
127.0.0.1

Usage

Usage of argyml is really easy, you pass it command-line arguments, options and flags:

argyml some arguments --host 127.0.0.1 -i --another-flag

and receive YAML in standard output:

- type: arg
  value: some
- type: arg
  value: arguments
- key: --host
  type: option
  value: 127.0.0.1
- key: -i
  type: flag
- key: --another-flag
  type: flag

Limitations

argyml parses the arguments on naive basis. Implications are the following:

  • it cannot be provided with any sort of schema for options, flags and arguments or their types 1

  • arguments cannot follow flags, otherwise they will be interpreted as options

Roadmap

  • Refactor
  • Option to directly generate a bash associative array?
  • Maybe figure out a way to provide schema for options, flags and arguments?

Footnotes

  1. For type casting you should rely on downstream. โ†ฉ

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.