Refactored, added comprehensive testing.
All checks were successful
Release / release (push) Successful in 3m17s

This commit is contained in:
Jay
2025-10-26 23:23:43 -04:00
parent ec32b75267
commit 1936f055e2
61 changed files with 4678 additions and 769 deletions

81
config/flags.go Normal file
View File

@@ -0,0 +1,81 @@
package config
import "flag"
type stringSlice []string
func (s *stringSlice) String() string {
if s == nil {
return ""
}
return ""
}
func (s *stringSlice) Set(value string) error {
*s = append(*s, value)
return nil
}
func parseFlags(args []string) (flagValues, error) {
fv := flagValues{}
fs := flag.NewFlagSet("aicli", flag.ContinueOnError)
fs.Usage = printUsage
var files stringSlice
var prompts stringSlice
// Input flags
fs.Var(&files, "f", "")
fs.Var(&files, "file", "")
fs.Var(&prompts, "p", "")
fs.Var(&prompts, "prompt", "")
fs.StringVar(&fv.promptFile, "pf", "", "")
fs.StringVar(&fv.promptFile, "prompt-file", "", "")
// System flags
fs.StringVar(&fv.system, "s", "", "")
fs.StringVar(&fv.system, "system", "", "")
fs.StringVar(&fv.systemFile, "sf", "", "")
fs.StringVar(&fv.systemFile, "system-file", "", "")
// API flags
fs.StringVar(&fv.key, "k", "", "")
fs.StringVar(&fv.key, "key", "", "")
fs.StringVar(&fv.keyFile, "kf", "", "")
fs.StringVar(&fv.keyFile, "key-file", "", "")
fs.StringVar(&fv.protocol, "l", "", "")
fs.StringVar(&fv.protocol, "protocol", "", "")
fs.StringVar(&fv.url, "u", "", "")
fs.StringVar(&fv.url, "url", "", "")
// Model flags
fs.StringVar(&fv.model, "m", "", "")
fs.StringVar(&fv.model, "model", "", "")
fs.StringVar(&fv.fallback, "b", "", "")
fs.StringVar(&fv.fallback, "fallback", "", "")
// Output flags
fs.StringVar(&fv.output, "o", "", "")
fs.StringVar(&fv.output, "output", "", "")
fs.StringVar(&fv.config, "c", "", "")
fs.StringVar(&fv.config, "config", "", "")
// Boolean flags
fs.BoolVar(&fv.stdinFile, "F", false, "")
fs.BoolVar(&fv.stdinFile, "stdin-file", false, "")
fs.BoolVar(&fv.quiet, "q", false, "")
fs.BoolVar(&fv.quiet, "quiet", false, "")
fs.BoolVar(&fv.verbose, "v", false, "")
fs.BoolVar(&fv.verbose, "verbose", false, "")
fs.BoolVar(&fv.version, "version", false, "")
if err := fs.Parse(args); err != nil {
return flagValues{}, err
}
fv.files = files
fv.prompts = prompts
return fv, nil
}