@@ -23,7 +23,7 @@ var cli struct {
2323 Version kong.VersionFlag `short:"V" help:"Print version information"`
2424 Verbose int `short:"v" type:"counter" help:"Increase verbosity (-v for debug, -vv for trace)"`
2525 LogFile string `name:"log-file" help:"Path to log file (supports ~ expansion)" env:"EPITHET_LOG_FILE"`
26- Config kong. ConfigFlag `help:"Path to config file"`
26+ Config kongcue. Config `help:"Path to config file" default:"~/.epithet/*.yaml,~/.epithet/*.yml,~/.epithet/*.cue,~/.epithet/*.json "`
2727
2828 // TLS configuration flags (global)
2929 Insecure bool `help:"Disable TLS certificate verification (NOT RECOMMENDED)" env:"EPITHET_INSECURE"`
@@ -37,30 +37,17 @@ var cli struct {
3737}
3838
3939func main () {
40- // Check if we're running in Lambda mode via environment variable
41- if epithetCmd := os .Getenv ("EPITHET_CMD" ); epithetCmd != "" {
42- // Parse the command from environment (e.g., "aws ca")
43- args := strings .Fields (epithetCmd )
44- os .Args = append ([]string {os .Args [0 ]}, args ... )
45- }
46-
47- // Load and unify config files
48- configPaths := []string {
49- "~/.epithet/*.yaml" ,
50- "~/.epithet/*.yml" ,
51- "~/.epithet/*.cue" ,
52- "~/.epithet/*.json" ,
53- }
54-
55- unifiedConfig , err := kongcue .LoadAndUnifyPaths (configPaths )
56- if err != nil {
57- slog .Error ("failed to load config" , "error" , err )
58- os .Exit (1 )
40+ // we also allow command to be named epithet-agent and such, to imply a command
41+ if baseName := filepath .Base (os .Args [0 ]); strings .Contains (baseName , "-" ) {
42+ parts := strings .SplitN (baseName , "-" , 2 )
43+ if len (parts ) == 2 {
44+ // Transform [epithet-policy, --woof, --meow] -> [epithet, policy, --woof, --meow]
45+ os .Args = append ([]string {parts [0 ], parts [1 ]}, os .Args [1 :]... )
46+ }
5947 }
6048
6149 ktx := kong .Parse (& cli ,
6250 kong.Vars {"version" : version + " (" + commit + ", " + date + ")" },
63- kong .Resolvers (kongcue .NewResolver (unifiedConfig )),
6451 )
6552 logger := setupLogger ()
6653
@@ -72,8 +59,7 @@ func main() {
7259
7360 ktx .Bind (logger )
7461 ktx .Bind (tlsCfg )
75- ktx .Bind (unifiedConfig ) // Bind CUE value for commands that need full config (e.g., policy)
76- err = ktx .Run ()
62+ err := ktx .Run ()
7763 if err != nil {
7864 logger .Error ("error" , "error" , err )
7965 os .Exit (1 )
0 commit comments