Skip to content

glacier new

Synopsis. Add a package, command, or functional-option constructor to an existing Glacier project.

Other commands: vibe version generate lint test init completions explain

Subcommands

SubcommandDescription
glacier new package <name>Create a new Go package skeleton (doc.go, <name>.go, <name>_test.go)
glacier new command <name>Create a new +glacier:command struct and re-run cli/gen.Generate
glacier new option <TypeName>Append a functional-option constructor to options.go in the target package

Flags for new package

FlagDefaultDescription
<name>(required)Package directory name
--pkg(same as name)Go package name if different from the directory name
--dry-runfalsePrint what would be created without writing any files
--forcefalseOverwrite existing files

Flags for new command

FlagDefaultDescription
<name>(required)Command name (becomes the verb)
--parentrootParent command name in the tree
--dry-runfalsePrint the plan without writing files
--forcefalseOverwrite existing files

Flags for new option

FlagDefaultDescription
<TypeName>(required)The type the option configures
--pkg.Package path where options.go lives
--dry-runfalsePrint the generated code without writing it
--forcefalseOverwrite existing files

Examples

Create a new package skeleton:

sh
glacier new package auth

Preview a new command without writing it:

sh
glacier new command pause --dry-run

Add a command under a specific parent:

sh
glacier new command pause --parent=serve

Generate a functional-option constructor for ServerConfig:

sh
glacier new option ServerConfig

Preview the option code without writing:

sh
glacier new option ServerConfig --dry-run

What it does under the hood

new package validates the name as a Go identifier, walks to the module root by finding go.mod, and writes three files atomically via internal/safefile. new command locates the directory containing zz_generated_cli.go by walking the module tree, writes the command stub, then calls cli/gen.Generate in-process to regenerate the wiring. new option reads the existing package name from a sibling .go file, generates the <TypeName>Option type and With<TypeName> constructor, formats with go/format, and appends to options.go (creating it if absent).

Exit codes

CodeMeaning
0Success
2Usage error
64Codegen re-run failed after new command
67No module found, file collision without --force, invalid name, or write failure
130SIGINT

See also

Apache-2.0