cli, lib, lang: Port to new cli library

The new version of the urfave/cli library is moving to generics, and
it's completely unclear to me why this is an improvement. Their new API
is very complicated to understand, which for me, defeats the purpose of
golang.

In parallel, I needed to do some upcoming cli API refactoring, so this
was a good time to look into new libraries. After a review of the
landscape, I found the alexflint/go-arg library which has a delightfully
elegant API. It does have a few rough edges, but it's otherwise very
usable, and I think it would be straightforward to add features and fix
issues.

Thanks Alex!
This commit is contained in:
James Shubin
2024-03-01 18:09:06 -05:00
parent e767655ede
commit 589a5f9aeb
32 changed files with 609 additions and 1047 deletions

13
main.go
View File

@@ -18,6 +18,7 @@
package main
import (
"context"
_ "embed"
"fmt"
"os"
@@ -29,8 +30,9 @@ import (
// These constants are some global variables that are used throughout the code.
const (
Debug = false // add additional log messages
Verbose = false // add extra log message output
tagline = "next generation config management"
debug = false // add additional log messages
verbose = false // add extra log message output
)
// set at compile time
@@ -60,13 +62,14 @@ func main() {
Program: program,
Version: version,
Copying: copying,
Tagline: tagline,
Flags: cliUtil.Flags{
Debug: Debug,
Verbose: Verbose,
Debug: debug,
Verbose: verbose,
},
Args: os.Args,
}
if err := cli.CLI(data); err != nil {
if err := cli.CLI(context.Background(), data); err != nil {
fmt.Println(err)
os.Exit(1)
return