GithubHelp home page GithubHelp logo

corona10 / fuego Goto Github PK

View Code? Open in Web Editor NEW
39.0 5.0 6.0 896 KB

fuego is a library for automatically generating command line interfaces (CLIs) from function and struct.

License: BSD 3-Clause "New" or "Revised" License

Go 100.00%
cli go golang python fire google

fuego's Introduction

Build Status GoDoc Go Report Card Coverage Status License

fuego

Inspired by Google python-fire

fuego is a library for automatically generating command line interfaces (CLIs) from function and struct.

Features

  • fuego is a simple way to create a CLI in Go.
  • fuego helps with exploring existing code or turning other people's code into a CLI. [1]
  • fuego shows documentation of each method or functions for help.

Installation

go get github.com/corona10/fuego

TODO

  • Support flag options
  • More error handling
  • Support more types

asciicast

package main

import (
	"fmt"

	"github.com/corona10/fuego"
)

func Add(a int, b int) (int, int) {
	fmt.Println(a, b)
	return a + b, 2*a + b
}

func main() {
	fuego.Fire(Add)
}
package main

import (
	"fmt"

	"github.com/corona10/fuego"
)

type Sample struct {
	Name string
}

func (s Sample) Add(a, b int) int {
	return a + b
}

func (s Sample) Minus(a, b int) int {
	return a - b
}

func (s Sample) HelloWorld() {
	fmt.Println(s.Name)
	fmt.Println("Hello world!")
}

func main() {
	var s Sample
	s.Name = "test"
	fuego.Fire(s)
}

Special thanks to

fuego's People

Contributors

corona10 avatar sherylynn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

fuego's Issues

Error handling is needed

For example,

package main

import (
	"fmt"

	"github.com/corona10/fuego"
)

type Sample struct {
	Name string
}

func (s Sample) Add(a, b int) int {
	return a + b
}

func (s Sample) Minus(a, b int) int {
	return a - b
}

func (s Sample) HelloWorld() {
	fmt.Println(s.Name)
	fmt.Println("Hello world!")
}

func main() {
	var s Sample
	s.Name = "test"
	fuego.Fire(s)
}
go run example2.go do not

This should be handled as an error and should not be succeeded.
Due to this line of codes https://github.com/corona10/fuego/blob/master/sym.go#L33
There are no error handlings for wrong types, it should be added.

Pretty help command

The current command list is not pretty.
We need to improve it as much as python-fire

Package level documentation extraction should be supported.

package main

import (
	"github.com/corona10/fuego"
	"github.com/corona10/goimghdr"
)

func main() {
	fuego.Fire(goimghdr.What)
}

This code is able to run through fuego.
but fail to extract documentation from the package.
This issue should be solved.

$ go run example4.go 
Usage of example4:
example4 string -> Documentation of What should be found from AST information.

DocString for command lists.

When fuego show command lists.
It only shows command and function/methods parameters.

Usage:  example2
example2 Add int int -> Add is a method for the sum of two values.

If fuego can show this way, it would be great.

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.