Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
github.com/pnelson/cli-reflection
Note: I don't really like this structure any more. I've opted for a more simple, reflection-free structure. See https://github.com/pnelson/cli and consider this package deprecated.
Package cli provides structure for command line applications with sub-commands.
This package uses a touch of reflection magic to dispatch to a method with named arguments. Commands help and version are implemented by default. The usage information is pretty printed in an opinionated format.
The most basic cli application is boring:
app := cli.New("myapp", "0.0.1") app.Run()
Build and run your application:
$ ./myapp Usage: myapp [options] [] help Output this usage information. version Output the application version
Add commands:
type add struct { showExtra *bool example *string number *int }
func (c *add) Flags(flags *flag.FlagSet) { c.showExtra = flags.Bool("show-extra", false, "Print extra arguments.") c.example = flags.String("example", "", "An example string option.") c.number = flags.Int("number", 0, "An example int option.") }
func (c *add) Run(key, username string, extra []string) { fmt.Printf("%s => %s\n", key, username) if *c.showExtra { fmt.Printf(" %v\n", extra) } }
func (c *add) String() string { return "Add record key with username." }
func main() { app := cli.New("myapp", "0.0.1") app.Rule(&add{}, "add", " []") app.Run() }
Try building and running your application again:
$ ./myapp Usage: myapp [options] [] help Output this usage information. version Output the application version. add [options] [] Add record key with username. -example= An example string option. -number= An example int option. -show-extra Print extra arguments.
Copyright (c) 2014 by Philip Nelson. See LICENSE for details.
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.