So talking about ticket: <DEV-3093 Create a cli co...
# atmos-dev
s
So talking about ticket: DEV-3093 Create a cli command core library I went into depth of setting config with the help of viper and cobra alone. There are certain things that i found: 1. Flags are only parsed once root.Execute happens and therefore logs-level, logs-file might have to be manually parsed at the start (Which i don't like) 2. others would be handled as most of them don't need to be initialized before the command. So i am thinking of handling all other flags based on the common config structure except the logs-level. Are we fine with this or should i try more to find a way to fix the logs-level issue. cc: @Erik Osterman (Cloud Posse) @Andriy Knysh (Cloud Posse)
Note: I already spent some time trying to find a fix... but i don't think this is possible
e
I am okay with the conclusion, but not sure that I underhand why log arguments are special, say, as opposed to other arguments like —base-path
s
we start logging even before we enter the root command starts to execute. and just because cobra does not parse the flags and set them before root.Execute our logging could miss the flag "if set by the user" Though only for the part before root Command but that is a loss and inconsistency which we want to avoid.
👍 1
e
Can you paraphrase all this and add it to the PR Description
I.e. with ChatGPT
s
sure...
a
we also parse the custom commands before Cobra does anything, and we log from the parsing
s
yep that is why logging is important to use before even reaching root command... already noted
Same ticket, different question: While migrating i came accross
base-path
flag. This flag is not in the help section of
atmos --help
Was this on purpose? I don't think so. But i guess then this migration is helping us in making this more streamline 🙂
e
Eeek
How can we avoid these kinds of shadow args from entering into cobra?
s
What do we mean by shadow args? Was it purposely hidden?
if want the flag to be hidden we can set it to hidden 😅
a
it should not be hidden, it was not included in the first place, please add it
s
Thanks for confirming.
How can we avoid these kinds of shadow args from entering into cobra?
This was hidden because we used to manually process args so it made it work even without adding it to cobra. Anyway now that we are centralizing this would be solved 🙂
Copy code
stacks:
  # Can also be set using 'ATMOS_STACKS_BASE_PATH' ENV var, or '--config-dir' and '--stacks-dir' command-line arguments
  # Supports both absolute and relative paths
  base_path: "stacks"
Why do we have two flags that do the same thing? is it really necessary?
a
—config-dir is a very old and obsolete, don’t use it
and don’t document it
s
makes sense
e
Yes, don't support
--config-dir
. Also, we should use
stacks-base-path
for consistency (and mark the other flag as deprecated)
s
Why did we use cue?
Copy code
cueBasePath := os.Getenv("ATMOS_SCHEMAS_CUE_BASE_PATH")
	if len(cueBasePath) > 0 {
		log.Debug("Set atmosConfig.Schemas[\"cue\"] using ENV", "ATMOS_SCHEMAS_CUE_BASE_PATH", cueBasePath)
		atmosConfig.Schemas["cue"] = schema.ResourcePath{
			BasePath: cueBasePath,
		}
	}
I did not find any
cue
reference... looks like this one needs cleaning as well
a
please clean it up
we wanted to support Cue in the past, but probably won’t