Giter Site home page Giter Site logo

venom's People

Contributors

themalkolm avatar

Stargazers

 avatar  avatar

Watchers

 avatar

venom's Issues

Add LogObject

func LogObject(in interface{}, output string, lvl logrus.Level) error {
	w := logrus.StandardLogger().WriterLevel(lvl)
        defer w.Close()

	return venom.WriteObject(in, venom.Format(output), w)
}

Something like this. A way to write object to log.

Why do we have RawFormat again?

Not sure we need this.. simply passing bytes to a function so it writes them to the writer we pass to this function as well.. weeird.

Add support for custom validation

e.g.

func (c *FooConfig) Validate() (err *multierror.Error) {
	...
	return err
}

If we define this method it should be invoked during flag parsing to ensure the config is valid e.g.

var cfg FooConfig
err := venom.Validate(&cfg)

This will go and recursively run Validate for all flag-tagged struct etc.

Add gen-config command

It would be nice to automatically generate config structure for any command e.g.

var RootCmd = &cobra.Command{
	Use:          "foobar",
...
func init() {
	//
	// You need to define flags as usual.
	//
	RootCmd.PersistentFlags().String("foo", "", "Some foonees must be set")
	RootCmd.PersistentFlags().String("foo-bar", "", "Some barness must be set")
...
$ foobar gen-config -o ./config.go
...
$ cat ./config.o
type Config struct {
	Foo    string `mapstructure:"foo"`
	FooBar string `mapstructure:"foo-bar"`
}

So kind of self-updating code. The tricky part is to how to start this process. This could be done simply by having a dummy struct in the beginning to make sure code compiles.

Support trivial type conversion for default values

WORKS

type Foo struct {
    bar string `flag:"bar,bananza,Barness"`
}

DOESN'T WORK

type Bar string
type Foo struct {
    bar Bar `flag:"bar,bananza,Barness"`
}

While it is still a string, it works only in the first case.

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.