Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
github.com/bad33ndj3/commander
Commander is a simple, structured CLI framework built as an alternative to Make/Mage for Go projects. It was created out of a need for a more Go-idiomatic build tool that leverages Go's type system and provides better IDE support.
⚠️ Note: This project is currently in an experimental stage and may not be production-ready. Features may change, and there might be bugs. Use it at your own risk.
I would advise you to use https://taskfile.dev/ since its a complete package.
Here's a minimal example to get started:
package main
import (
"context"
"fmt"
"github.com/bad33ndj3/commander"
)
func main() {
cmdr := commander.New()
rootCat := cmdr.AddCategory("Root")
rootCat.Register(&commander.Command{
Name: "hello",
Description: "Prints Hello World",
Handler: helloHandler,
})
if err := cmdr.Run(); err != nil {
fmt.Println(err)
}
}
func helloHandler(ctx context.Context) {
fmt.Println("Hello, World!")
}
Include the commander
package in your project by importing it.
go get github.com/bad33ndj3/commander
Commands are defined using handler functions and argument structs. Handler functions must accept context.Context
as the first parameter and an optional struct for arguments.
type BuildArgs struct {
Debug bool `flag:"debug" default:"false" usage:"Enable debug mode"`
Output string `flag:"output" default:"./bin" usage:"Output directory"`
Version string `flag:"version" default:"dev" usage:"Build version"`
}
type TestArgs struct {
Verbose bool `flag:"verbose" default:"false" usage:"Enable verbose output"`
Pattern string `flag:"pattern" default:"./..." usage:"Test pattern to run"`
}
Initialize Commander
, add categories, and register commands:
func main() {
cmdr := commander.New()
buildCat := cmdr.AddCategory("Build")
testCat := cmdr.AddCategory("Test")
buildCat.Register(&commander.Command{
Name: "build",
Description: "Build the project",
Handler: buildHandler,
})
testCat.Register(&commander.Command{
Name: "test",
Description: "Run tests",
Handler: testHandler,
})
if err := cmdr.Run(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
Display general help:
go run main.go help
Display help for a specific command:
go run main.go help build
flag:"name"
: Custom flag name (default is field name in lowercase).default:"value"
: Default value for the flag.usage:"description"
: Help text displayed in the help message.context.Context
.bool
, int
, string
.This project is licensed under the MIT License - see the LICENSE file for details.
The commander
package simplifies the creation of CLI applications by using Go's native features. By defining commands with clear handler functions and argument structs, you can build intuitive and maintainable command-line tools efficiently.
For more examples and advanced usage, refer to the package documentation or the examples directory in the repository.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.