go-cli: github.com/motemen/go-cli/gen Index | Files

package gen

import "github.com/motemen/go-cli/gen"

Package gen generates github.com/motemen/go-cli.Command from function docs in files specified.

Index

Package Files

gen.go

func Generate Uses

func Generate(w io.Writer, path string, src interface{}) error

Generate reads source file for command actions with their usage documentations and writes Go code that registers the command to cli.

Usage documentation should be like below:

// +command <name> - <short>
//
// <usage line>
//
// <long description>...
func action(flags *flag.FlagSet, args []string) {
}

Currently, generated files will be like below:

// auto-generated file

package main

import "github.com/motemen/go-cli"

func init() {
    cli.Use(
        &cli.Command{
            Name:   "foo",
            ...
        }
    )
    ...
}

You can define `main action` without sub-command. Usage documentation of main action should be like below:

// +main - <short>
//
// <usage line>
//
// <long description>...
func mainAction(flags *flag.FlagSet, args []string) {
	...
}

Package gen imports 7 packages (graph) and is imported by 2 packages. Updated 2018-02-26. Refresh now. Tools for package owners.