
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
go.coder.com/cli
A minimal, command-oriented CLI package.
go get -u go.coder.com/cli
See examples/
for more.
package main
import (
"fmt"
"github.com/spf13/pflag"
"go.coder.com/cli"
)
type cmd struct {
verbose bool
}
func (c *cmd) Run(fl *pflag.FlagSet) {
if c.verbose {
fmt.Println("verbose enabled")
}
fmt.Println("we run")
}
func (c *cmd) Spec() cli.CommandSpec {
return cli.CommandSpec{
Name: "simple-example",
Usage: "[flags]",
Desc: `This is a simple example of the cli package.`,
}
}
func (c *cmd) RegisterFlags(fl *pflag.FlagSet) {
fl.BoolVar(&c.verbose, "v", false, "sets verbose mode")
}
func main() {
cli.RunRoot(&cmd{})
}
renders a help like
Usage: simple-example [flags]
This is a simple example of the cli package.
simple-example flags:
-v sets verbose mode (false)
package main
import (
"fmt"
"github.com/spf13/pflag"
"go.coder.com/cli"
)
type subcmd struct {
}
func (c *subcmd) Run(fl *pflag.FlagSet) {
fmt.Println("subcommand invoked")
}
func (c *subcmd) Spec() cli.CommandSpec {
return cli.CommandSpec{
Name: "sub",
Usage: "",
Aliases: []string{"s"},
Desc: `This is a simple subcommand.`,
}
}
type cmd struct {
}
func (c *cmd) Run(fl *pflag.FlagSet) {
// This root command has no default action, so print the help.
fl.Usage()
}
func (c *cmd) Spec() cli.CommandSpec {
return cli.CommandSpec{
Name: "subcommand",
Usage: "[flags]",
Desc: `This is a simple example of subcommands.`,
}
}
func (c *cmd) Subcommands() []cli.Command {
return []cli.Command{
&subcmd{},
}
}
func main() {
cli.RunRoot(&cmd{})
}
renders a help like
Usage: subcommand [flags]
This is a simple example of subcommands.
Commands:
s,sub - This is a simple subcommand.
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 researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.