gen

package
Version: v0.0.0-...-9961a87 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 5, 2018 License: MIT Imports: 7 Imported by: 8

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

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) {
	...
}

Types

This section is empty.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL