mkideal / cli

CLI - A package for building command line app with go
MIT License
730 stars 43 forks source link

Enable Wiki #13

Closed suntong closed 8 years ago

suntong commented 8 years ago

Hi 仕晋,

Please enable your CLI's Wiki.

I've got the following code automatically generated:

// -*- go -*-
package main

import (
    "github.com/mkideal/cli"
)

var _ = app.Register(&cli.Command{
    Name: "build",
    Desc: "Build golang application",
    Text: "Usage:\n  gogo build [Options] Arch(i386|amd64)",
    Argv: func() interface{} { return new(buildT) },
    Fn:   build,

    NumArg:      cli.ExactN(1),
    CanSubRoute: true,
})

type buildT struct {
    cli.Helper
    Dir  string  `cli:"dir" usage:"source code root dir" dft:"./"`
    Suffix  string  `cli:"suffix" usage:"source file suffix" dft:".go,.c,.s"`
    Out  string  `cli:"o,out" usage:"output filename"`
}

func build(ctx *cli.Context) error {
    argv := ctx.Argv().(*buildT)
    ctx.String("%s: %v", ctx.Path(), jsonIndent(argv))
    ctx.String("[build]: %v\n", ctx.Args())

    return nil
}

package main

import (
    "github.com/mkideal/cli"
)

var _ = app.Register(&cli.Command{
    Name: "install",
    Desc: "Install golang application",
    Text: "Usage:\n  gogo install [Options] package [package...]",
    Argv: func() interface{} { return new(installT) },
    Fn:   install,

    NumArg:      cli.AtLeast(1),
    CanSubRoute: true,
})

type installT struct {
    cli.Helper
    Dir  string  `cli:"dir" usage:"source code root dir" dft:"./"`
    Suffix  string  `cli:"suffix" usage:"source file suffix" dft:".go,.c,.s"`
    Out  string  `cli:"o,out" usage:"output filename"`
}

func install(ctx *cli.Context) error {
    argv := ctx.Argv().(*installT)
    ctx.String("%s: %v", ctx.Path(), jsonIndent(argv))
    ctx.String("[install]: %v\n", ctx.Args())

    return nil
}

I can explain how in your enabled CLI's Wiki.

mkideal commented 8 years ago

wiki enabled.

suntong commented 8 years ago

K. will do later...

suntong commented 8 years ago

Can't edit it.

I've edited other wiki before, so I know it is must be a permission issue.

mkideal commented 8 years ago

I'm sorry! Try again now.

suntong commented 8 years ago

Yep. Thx.