- promptForFilename setting (default true; env VERAE_PROMPT_FOR_FILENAME), 'verae-print config --prompt-for-filename', last Save As folder in ~/.verae/state.json - Windows helper: common file dialog (PDF filter, overwrite prompt, topmost owner) before stamping; macOS printer path: choose file name (NSSavePanel) via 'stamp -prompt-name -title'; cancel discards the job (no stamp/credit) - job.Options.OutPath: original saved at the chosen path, certificate and .verae.json next to it with the chosen base name (never overwritten) - held jobs keep the chosen path (pendingMeta.OutPath) - installer: 'Ask for a file name for each print' checkbox; removed the 'Open the user guide' finish-page checkbox; mac-key-setup asks too - auth test no longer touches the real macOS keychain (VERAE_SKIP_KEYCHAIN) - version 0.3.2
68 lines
2.2 KiB
Go
68 lines
2.2 KiB
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/VeraeLLC/PrintToVeraeTimeStamp/internal/settings"
|
|
"github.com/VeraeLLC/PrintToVeraeTimeStamp/internal/vlog"
|
|
)
|
|
|
|
// openOnComplete applies the OpenOnComplete setting after a successful stamp.
|
|
func openOnComplete(lj vlog.Job, certPDF string) {
|
|
s, src := settings.Load()
|
|
mode := s.OpenOnComplete
|
|
if mode == settings.OpenNone {
|
|
lj.Printf("open-on-complete: mode=none (from %s) — not opening", src)
|
|
return
|
|
}
|
|
if _, err := os.Stat(certPDF); err != nil {
|
|
lj.Errorf("open-on-complete: mode=%s target missing %q: %v", mode, certPDF, err)
|
|
return
|
|
}
|
|
err := openResult(mode, certPDF)
|
|
if err != nil {
|
|
lj.Errorf("open-on-complete: mode=%s (from %s) target=%q FAILED: %v", mode, src, certPDF, err)
|
|
return
|
|
}
|
|
lj.Printf("open-on-complete: mode=%s (from %s) target=%q OK", mode, src, certPDF)
|
|
}
|
|
|
|
// runConfig: verae-print config [--show] [--open-on-complete folder|pdf|none] [--file PATH | --machine]
|
|
func runConfig(args []string) int {
|
|
fs := flag.NewFlagSet("config", flag.ContinueOnError)
|
|
open := fs.String("open-on-complete", "", "folder | pdf | none")
|
|
file := fs.String("file", "", "config file to update (default ~/.verae/config.json)")
|
|
prompt := fs.String("prompt-for-filename", "", "true | false: show a Save As dialog for each print")
|
|
machine := fs.Bool("machine", false, "update the all-users default file instead")
|
|
if err := fs.Parse(args); err != nil {
|
|
return 2
|
|
}
|
|
path := settings.UserPath("")
|
|
if *machine {
|
|
path = settings.MachinePath()
|
|
}
|
|
if *file != "" {
|
|
path = *file
|
|
}
|
|
if *open != "" {
|
|
if err := settings.SetOpenOnComplete(path, *open); err != nil {
|
|
fmt.Fprintln(os.Stderr, err)
|
|
return 1
|
|
}
|
|
vlog.Init("cli", false)
|
|
vlog.Printf("config: openOnComplete=%s written to %s", settings.NormalizeOpen(*open), path)
|
|
}
|
|
if *prompt != "" {
|
|
if err := settings.SetPromptForFilename(path, *prompt); err != nil {
|
|
fmt.Fprintln(os.Stderr, err)
|
|
return 1
|
|
}
|
|
vlog.Init("cli", false)
|
|
vlog.Printf("config: promptForFilename=%s written to %s", *prompt, path)
|
|
}
|
|
s, src := settings.Load()
|
|
fmt.Printf("openOnComplete=%s (from %s)\npromptForFilename=%v\nuser file: %s\nmachine file: %s\n", s.OpenOnComplete, src, s.Prompt(), settings.UserPath(""), settings.MachinePath())
|
|
return 0
|
|
}
|