mirror of
https://github.com/la5nta/pat
synced 2026-08-07 22:32:06 -04:00
43 lines
954 B
Go
43 lines
954 B
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"log"
|
|
"strconv"
|
|
|
|
"github.com/la5nta/pat/app"
|
|
)
|
|
|
|
const (
|
|
TemplatesUsage = `subcommand [option ...]
|
|
|
|
subcommands:
|
|
update Update standard Winlink form templates.
|
|
seqset [number] Set the template sequence value.
|
|
`
|
|
TemplatesExample = `
|
|
update Download the latest form templates from winlink.org.
|
|
seqset 0 Reset the current sequence value to 0.
|
|
`
|
|
)
|
|
|
|
func TemplatesHandle(ctx context.Context, app *app.App, args []string) {
|
|
switch cmd, args := shiftArgs(args); cmd {
|
|
case "update":
|
|
if _, err := app.FormsManager().UpdateFormTemplates(ctx); err != nil {
|
|
log.Printf("%v", err)
|
|
}
|
|
case "seqset":
|
|
v, err := strconv.Atoi(args[0])
|
|
if err != nil {
|
|
log.Printf("invalid sequence number: %q", args[0])
|
|
return
|
|
}
|
|
if err := app.FormsManager().SeqSet(v); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
default:
|
|
fmt.Println("Missing argument, try 'templates help'.")
|
|
}
|
|
}
|