mirror of
https://git.sr.ht/~rjarry/aerc
synced 2025-12-18 12:00:10 +01:00
Add `desc:""` struct field tags in all command arguments where it makes sense. The description values will be returned along with completion choices. Implements: https://todo.sr.ht/~rjarry/aerc/271 Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bojan Gabric <bojan@bojangabric.com> Tested-by: Jason Cox <me@jasoncarloscox.com> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
46 lines
764 B
Go
46 lines
764 B
Go
package patch
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"git.sr.ht/~rjarry/aerc/commands"
|
|
"git.sr.ht/~rjarry/aerc/lib/pama"
|
|
)
|
|
|
|
type Init struct {
|
|
Force bool `opt:"-f" desc:"Overwrite any existing project."`
|
|
Name string `opt:"name" required:"false"`
|
|
}
|
|
|
|
func init() {
|
|
register(Init{})
|
|
}
|
|
|
|
func (Init) Description() string {
|
|
return "Create a new project."
|
|
}
|
|
|
|
func (Init) Context() commands.CommandContext {
|
|
return commands.GLOBAL
|
|
}
|
|
|
|
func (Init) Aliases() []string {
|
|
return []string{"init"}
|
|
}
|
|
|
|
func (i Init) Execute(args []string) error {
|
|
cwd, err := os.Getwd()
|
|
if err != nil {
|
|
return fmt.Errorf("Could not get current directory: %w", err)
|
|
}
|
|
|
|
name := i.Name
|
|
if name == "" {
|
|
name = filepath.Base(cwd)
|
|
}
|
|
|
|
return pama.New().Init(name, cwd, i.Force)
|
|
}
|