86 lines
2.5 KiB
Go
86 lines
2.5 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"os/user"
|
|
)
|
|
|
|
/*
|
|
this parses the command line arguements
|
|
|
|
this enables command line options from other packages like 'gui' and 'log'
|
|
*/
|
|
|
|
type args struct {
|
|
Quick *QuickCmd `arg:"subcommand:quick" help:"only do repos with patches"`
|
|
DryRun bool `arg:"--dry-run,env:DRYRUN" help:"don't actually do the release"`
|
|
Minor bool `arg:"--minor" help:"increment minor verion numbers"`
|
|
Protobuf bool `arg:"--protobuf" help:"increment protobuf repos"`
|
|
Verbose bool `arg:"--verbose" help:"talk alot"`
|
|
Full bool `arg:"--full" help:"build every package"`
|
|
Reason string `arg:"--reason" help:"tag message"`
|
|
Force bool `arg:"--force" help:"try harder than normal"`
|
|
Port int `arg:"--port" default:"9419" help:"do fun stuff with curl"`
|
|
Bash bool `arg:"--bash" help:"generate bash completion"`
|
|
BashAuto []string `arg:"--auto-complete" help:"does the actual autocompletion"`
|
|
}
|
|
|
|
type QuickCmd struct {
|
|
List *EmptyCmd `arg:"subcommand:list" help:"list available patches"`
|
|
Show *EmptyCmd `arg:"subcommand:show" help:"show a specific patch"`
|
|
NoLibs *EmptyCmd `arg:"subcommand:show" help:"skip libraries that aren't changed"`
|
|
}
|
|
|
|
type EmptyCmd struct {
|
|
}
|
|
|
|
func (a args) Description() string {
|
|
return `
|
|
Example usage:
|
|
guireleaser go.wit.com/apps/go-clone --increment --release --dry-run --reason "blerg"
|
|
|
|
This will pull down the go sources and
|
|
the repositories in the go.sum file using git clone`
|
|
}
|
|
|
|
func (args) Version() string {
|
|
return "guireleaser " + VERSION
|
|
}
|
|
|
|
/*
|
|
handles shell autocomplete
|
|
*/
|
|
|
|
func (a args) DoAutoComplete(argv []string) {
|
|
switch argv[0] {
|
|
case "checkout":
|
|
usr, _ := user.Current()
|
|
fmt.Println("user devel master " + usr.Username)
|
|
case "commit":
|
|
fmt.Println("--all")
|
|
case "config":
|
|
fmt.Println("add fix list delete")
|
|
case "list":
|
|
fmt.Println("--all --mine --favorites --private")
|
|
case "pull":
|
|
fmt.Println("--all --mine --favorites --private")
|
|
case "patch":
|
|
fmt.Println("--list --submit --show")
|
|
case "dirty":
|
|
fmt.Println("--show-files")
|
|
case "user":
|
|
fmt.Println("--force")
|
|
case "devel":
|
|
fmt.Println("--force")
|
|
case "master":
|
|
fmt.Println("--force")
|
|
default:
|
|
if argv[0] == ARGNAME {
|
|
// list the subcommands here
|
|
fmt.Println("--bash quick")
|
|
}
|
|
}
|
|
os.Exit(0)
|
|
}
|