
Security News
Node.js Moves Toward Stable TypeScript Support with Amaro 1.0
Amaro 1.0 lays the groundwork for stable TypeScript support in Node.js, bringing official .ts loading closer to reality.
github.com/daved/clic
Supply Chain Security
Vulnerability
Quality
Maintenance
License
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
go get github.com/daved/clic
Package clic provides streamlined POSIX-friendly CLI command parsing.
type Clic
func New(h Handler, name string, subs ...*Clic) *Clic
func NewFromFunc(f HandlerFunc, name string, subs ...*Clic) *Clic
func (c *Clic) Flag(val any, names, usage string) *flagset.Flag
func (c *Clic) Handle(ctx context.Context) error
func (c *Clic) Operand(val any, req bool, name, desc string) *operandset.Operand
func (c *Clic) Parse(args []string) error
func (c *Clic) Recursively(fn func(*Clic))
func (c *Clic) Usage() string
// see package docs for more
func main() {
// error handling omitted to keep example focused
var (
info = "default"
value = "unset"
)
// Associate HandlerFunc with command name
root := clic.NewFromFunc(printFunc(&info, &value), "myapp")
// Associate flag and operand variables with relevant names
root.Flag(&info, "i|info", "Set additional info.")
root.Operand(&value, true, "first_operand", "Value to be printed.")
// Parse the cli command as `myapp --info=flagval arrrg`
cmd, _ := c.Parse([]string{"--info=flagval", "arrrg"})
// Run the handler that Parse resolved to
_ = cmd.Handle(context.Background())
}
Three types of arguments are handled: commands (and subcommands), flags (and their values), and operands. Commands and subcommands can each define their own flags and operands. Arguments that are not subcommands or flag-related (no hyphen prefix, not a flag value), will be treated as operands.
Example argument layout:
command --flag=flag-value subcommand -f flag-value operand_a operand_b
See vtypes.Hydrate for supported flag/operand value types.
cmd.Usage()
value from the example above:
Usage:
myapp [FLAGS] <first_operand>
Flags for myapp:
-i, --info =STRING default: default
Set additional info.
The Tmpl type eases custom templating. Custom data can be attached to instances of Clic, FlagSet, Flag, OperandSet, and Operand via their Meta fields for use in templates. The default template construction function (NewUsageTmpl) can be used as a reference for custom templates.
POSIX-friendly:
Simple and powerful:
Package docs contain suggestions for three stages of application growth.
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
Amaro 1.0 lays the groundwork for stable TypeScript support in Node.js, bringing official .ts loading closer to reality.
Research
A deceptive PyPI package posing as an Instagram growth tool collects user credentials and sends them to third-party bot services.
Product
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.