GithubHelp home page GithubHelp logo

jumpaku / cyamli Goto Github PK

View Code? Open in Web Editor NEW
16.0 16.0 1.0 2.97 MB

A command line tool to generate command line interfaces for your command line tools from the YAML-based CLI schemas.

License: BSD 2-Clause "Simplified" License

Dockerfile 0.47% Go 68.81% Smarty 16.15% Makefile 2.35% HTML 12.13% Shell 0.09%

cyamli's People

Contributors

jumpaku avatar v8yte avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

v8yte

cyamli's Issues

About the command examples in the README.

Shouldn't we fix the command examples in the README?

go run main.go cli.gen.go list -c=config.yaml
go run main.go cli.gen.go fetch -c=config.yaml -v table1 table2

bug with python3

cli.yaml

name: demo
description: demo app to get table information from databases
subcommands:
  list:
    description: list tables
    options:
      -config:
        description: path to config file
        short: -c
  describe:
    description: show information of tables
    options:
      -config:
        description: path to config file
        short: -c
      -verbose:
        description: shows detailed log
        short: -v
        type: boolean
    arguments:
      - name: tables
        variadic: true
        description: names of tables to be described

main..py

import cli_gen
import sys


def func(args, err):
    if err is not None:
        raise err
    print(args)


cli = cli_gen.CLI()
cli.FUNC = func
cli.list.FUNC = func
cli.describe.FUNC = func

cli_gen.run(cli, sys.argv)
cyamli python3 -schema-path=cli.yaml -out-path=cli_gen.py
python main.py describe -c=config.json -v T1 T2 T3
Traceback (most recent call last):
  File "/work/main.py", line 16, in <module>
    cli_gen.run(cli, sys.argv)
  File "/work/cli_gen.py", line 178, in run
    cli.describe.FUNC(input, ex)
  File "/work/main.py", line 7, in func
    raise err
  File "/work/cli_gen.py", line 175, in run
    input = resolve_CLI_Describe_Input(rest_args)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/work/cli_gen.py", line 92, in resolve_CLI_Describe_Input
    split[1] = "True"
    ~~~~~^^^
IndexError: list assignment index out of range

Like typical Linux commands

Like typical Linux commands, there are times when a main command with options is sufficient, without the need for a subcommand.
I think it would be better if the subcommand were not mandatory, as shown below. What do you think?

<program> [<subcommand>] [<option>|<argument>]... [-- [<argument>]...]

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.