Giter Club home page Giter Club logo

argify's Introduction

argify

convention based, argument/flag for awesome urfave/cli

status

Not thoroughly tested, for anyone interested!

in less fun words; WIP, tests, etc etc

quick peek

We can define a config struct as (sample):

type CouchDBInfo struct {
	URL      string
	User     string
	Password string
	DBName   string
}

// ConfPile sample conf struct
type ConfPile struct {
	Version1 string `name:"v1" usage:"--v1 0.0.1" hidden:"false" envvar:"V1" value:"0.0.1"`
	Version2 string `name:"v2" usage:"--v2 0.0.1" hidden:"false" value:"0.0.1"`

	FBool     bool
	FDuration time.Duration
	FFloat64  float64
	FInt64    int64
	FInt      int `value:"33"`
	FString   string
	FUint     uint   `value:"2"`
	FUint64   uint64 `value:"66"`

    // embedded structs would produce arguments with names like --<field name>-<embedded field name>
	App struct {
		LogDir       string
		PostponeExit time.Duration
		Env          string
		Version1     string
	}

	// one object for each database
	PrimaryDB CouchDBInfo

    // we have a command named 'start', so these would get added as it's arguments
	Start struct {
		Path     string `name:"path,p" usage:"-p ~/C" hidden:"false" value:"/tmp"`
		Interval int
	}
}

And then load it from a file. It's fields would get bind to cli's flags. If there is a non-zero vlue, it will be used as default value. Also values can get defined using Go struct tags.

Having an instance of *cli.App, after commands and subcommands are defined all we have to do is argify.NewArgify().Build(app, &cnf).

argify's People

Contributors

dc0d avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.