1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276
|
// redo - global option redo
//
// Redo global option via automatic code-gen
package main
////////////////////////////////////////////////////////////////////////////
// Program: redo
// Purpose: global option redo
// Authors: Myself <me@mine.org> (c) 2022-2023, All rights reserved
////////////////////////////////////////////////////////////////////////////
import (
// "fmt"
// "os"
// "github.com/go-easygen/go-flags"
)
// Template for main starts here
//////////////////////////////////////////////////////////////////////////
// Constant and data type/structure definitions
////////////////////////////////////////////////////////////////////////////
// Global variables definitions
// var (
// progname = "redo"
// version = "0.1.0"
// date = "2023-01-23"
// // opts store all the configurable options
// opts optsT
// )
//
// var gfParser = flags.NewParser(&opts, flags.Default)
////////////////////////////////////////////////////////////////////////////
// Function definitions
//==========================================================================
// Function main
// func main() {
// opts.Version = showVersion
// opts.Verbflg = func() {
// opts.Verbose++
// }
//
// if _, err := gfParser.Parse(); err != nil {
// fmt.Println()
// gfParser.WriteHelp(os.Stdout)
// os.Exit(1)
// }
// fmt.Println()
// //DoRedo()
// }
//
// //==========================================================================
// // support functions
//
// func showVersion() {
// fmt.Fprintf(os.Stderr, "redo - global option redo, version %s\n", version)
// fmt.Fprintf(os.Stderr, "Built on %s\n", date)
// fmt.Fprintf(os.Stderr, "Copyright (C) 2022-2023, Myself <me@mine.org>\n\n")
// fmt.Fprintf(os.Stderr, "Redo global option via automatic code-gen\n")
// os.Exit(0)
// }
// Template for main ends here
// DoRedo implements the business logic of command `redo`
// func DoRedo() error {
// return nil
// }
// Template for type define starts here
// The optsT type defines all the configurable options from cli.
type optsT struct {
Host string `short:"H" long:"host" env:"REDO_HOST" description:"Host address" default:"localhost"`
Port int `short:"p" long:"port" env:"REDO_PORT" description:"Listening port" default:"80"`
Force bool `short:"f" long:"force" env:"REDO_FORCE" description:"Force start"`
Verbflg func() `short:"v" long:"verbose" description:"Verbose mode (Multiple -v options increase the verbosity)"`
Verbose int
Version func() `short:"V" long:"version" description:"Show program version and exit"`
}
// Template for type define ends here
// Template for "build" CLI handling starts here
////////////////////////////////////////////////////////////////////////////
// Program: redo
// Purpose: global option redo
// Authors: Myself <me@mine.org> (c) 2022-2023, All rights reserved
////////////////////////////////////////////////////////////////////////////
// package main
// import (
// "fmt"
// "os"
//
// "github.com/go-easygen/go-flags/clis"
// )
// *** Sub-command: build ***
////////////////////////////////////////////////////////////////////////////
// Constant and data type/structure definitions
// The BuildCommand type defines all the configurable options from cli.
// type BuildCommand struct {
// Dir string `long:"dir" description:"source code root dir" default:"./"`
// }
//
// var buildCommand BuildCommand
//
// ////////////////////////////////////////////////////////////////////////////
// // Function definitions
//
// func init() {
// gfParser.AddCommand("build",
// "Build the network application",
// "Usage:\n redo build [Options] Arch(i386|amd64)",
// &buildCommand)
// }
//
// func (x *BuildCommand) Execute(args []string) error {
// fmt.Fprintf(os.Stderr, "Build the network application\n")
// // fmt.Fprintf(os.Stderr, "Copyright (C) 2022-2023, Myself <me@mine.org>\n\n")
// clis.Setup("redo::build", opts.Verbose)
// clis.Verbose(1, "Doing Build, with %+v, %+v", opts, args)
// // fmt.Println(x.Dir)
// return x.Exec(args)
// }
//
// // Exec implements the business logic of command `build`
// func (x *BuildCommand) Exec(args []string) error {
// // err := ...
// // clis.WarnOn("build::Exec", err)
// // or,
// // clis.AbortOn("build::Exec", err)
// return nil
// }
// Template for "build" CLI handling ends here
// Template for "install" CLI handling starts here
////////////////////////////////////////////////////////////////////////////
// Program: redo
// Purpose: global option redo
// Authors: Myself <me@mine.org> (c) 2022-2023, All rights reserved
////////////////////////////////////////////////////////////////////////////
// package main
// import (
// "fmt"
// "os"
//
// "github.com/go-easygen/go-flags/clis"
// )
// *** Sub-command: install ***
////////////////////////////////////////////////////////////////////////////
// Constant and data type/structure definitions
// The InstallCommand type defines all the configurable options from cli.
// type InstallCommand struct {
// Dir string `short:"d" description:"source code root dir" default:"./"`
// Suffix string `long:"suffix" description:"source file suffix" default:".go,.c,.s"`
// }
//
// var installCommand InstallCommand
//
// ////////////////////////////////////////////////////////////////////////////
// // Function definitions
//
// func init() {
// gfParser.AddCommand("install",
// "Install the network application",
// "The add command adds a file to the repository. Use -a to add all files",
// &installCommand)
// }
//
// func (x *InstallCommand) Execute(args []string) error {
// fmt.Fprintf(os.Stderr, "Install the network application\n")
// // fmt.Fprintf(os.Stderr, "Copyright (C) 2022-2023, Myself <me@mine.org>\n\n")
// clis.Setup("redo::install", opts.Verbose)
// clis.Verbose(1, "Doing Install, with %+v, %+v", opts, args)
// // fmt.Println(x.Dir, x.Suffix)
// return x.Exec(args)
// }
//
// // Exec implements the business logic of command `install`
// func (x *InstallCommand) Exec(args []string) error {
// // err := ...
// // clis.WarnOn("install::Exec", err)
// // or,
// // clis.AbortOn("install::Exec", err)
// return nil
// }
// Template for "install" CLI handling ends here
// Template for "publish" CLI handling starts here
////////////////////////////////////////////////////////////////////////////
// Program: redo
// Purpose: global option redo
// Authors: Myself <me@mine.org> (c) 2022-2023, All rights reserved
////////////////////////////////////////////////////////////////////////////
// package main
// import (
// "fmt"
// "os"
//
// "github.com/go-easygen/go-flags/clis"
// )
// *** Sub-command: publish ***
////////////////////////////////////////////////////////////////////////////
// Constant and data type/structure definitions
// The PublishCommand type defines all the configurable options from cli.
// type PublishCommand struct {
// Dir string `short:"d" long:"dir" description:"publish dir" required:"true"`
// Suffix []string `short:"s" long:"suffix" description:"source file suffix for publish" choice:".go" choice:".c" choice:".h"`
// Out string `short:"o" long:"out" description:"output filename"`
//
// // Example of positional arguments
// Args struct {
// ID string
// Num int
// Rest []string
// } `positional-args:"yes" required:"yes"`
// }
//
// var publishCommand PublishCommand
//
// ////////////////////////////////////////////////////////////////////////////
// // Function definitions
//
// func init() {
// gfParser.AddCommand("publish",
// "Publish the network application",
// "Publish the built network application to central repo",
// &publishCommand)
// }
//
// func (x *PublishCommand) Execute(args []string) error {
// fmt.Fprintf(os.Stderr, "Publish the network application\n")
// // fmt.Fprintf(os.Stderr, "Copyright (C) 2022-2023, Myself <me@mine.org>\n\n")
// clis.Setup("redo::publish", opts.Verbose)
// clis.Verbose(1, "Doing Publish, with %+v, %+v", opts, args)
// // fmt.Println(x.Dir, x.Suffix, x.Out, x.Args)
// return x.Exec(args)
// }
//
// // Exec implements the business logic of command `publish`
// func (x *PublishCommand) Exec(args []string) error {
// // err := ...
// // clis.WarnOn("publish::Exec", err)
// // or,
// // clis.AbortOn("publish::Exec", err)
// return nil
// }
// Template for "publish" CLI handling ends here
|