Warning
This library is a work in progress, bugs are fully expected. Do not use this for production applications for the time being!
Contributions for bugfixes and new features are welcome!
lithium
is a Golang v1.24+ library is an CLI toolkit for actions and flags.
The inspiration behind this came during the development of pixlic, where I wanted to have actions that would either let me choose the correct generator and pass n number of specific flags to it, and existing frameworks like Cobra were too opinionated for me use, so I decided to roll it myself.
Please also keep in mind that the initial commit is essentially a straight port from the pixlic code, and as such is still customized for it, so the code needs some more work before it's ready to shine.
lithium
is largely built on top of the standard library flag package, however support for the POSIX compliant pflag could also be implemented easily, however that's not something that's planned for now.
Whilst the project is very much still a work in progress, feature requests and contributions are very welcome. If you'd like to chit chat over coffee rather then create issue tickets for mundane stuff like inqueries, shoot me an E-Mail over at [email protected] or a DM on Discord @luxploit.net
./yourapp Test1 --test 2 # Invokes the Test1 action
./yourapp Test2 --test="lalalalala" # Invokes the Test2 action
./yourapp help
Usage: yourapp <action>
Test1 options:
--test <int64> set your silly test integer (Default: 0)
Test1 support notes:
this is an option support section
Test2 options:
--test <string> set your silly test string (Default: "")
Test2 support notes:
this is another option support section
This help menu can be brought up again by running "./yourapp help"
// main.go
func main() {
lithium.NewAction(&actions.Test1{})
lithium.NewAction(&actions.Test2{})
lithium.Execute()
}
// actions/test1.go
type Test1 struct {
testInt64 *int64
}
func (Test1) Name() string {
return "Test1"
}
func (t *Test1) Init(flags *lithium.Flags) {
p.testInt64 = flags.Int64("test", 0, "set your silly test integer")
}
func (Test1) Support() {
fmt.Printf("\tthis is an option support section")
}
// actions/test2.go
type Test2 struct {
testString *string
}
func (Test2) Name() string {
return "Test2"
}
func (t *Test2) Init(flags *lithium.Flags) {
p.testString = flags.String("test", "", "set your silly test string")
}
func (Test2) Support() {
fmt.Printf("\tthis is another option support section")
}