mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-04-20 19:38:39 +00:00
use yaml config file
This commit is contained in:
@@ -5,19 +5,30 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/smira/commander"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
func aptlyConfigShow(_ *commander.Command, _ []string) error {
|
||||
show_yaml := context.Flags().Lookup("yaml").Value.Get().(bool)
|
||||
|
||||
config := context.Config()
|
||||
prettyJSON, err := json.MarshalIndent(config, "", " ")
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to dump the config file: %s", err)
|
||||
if show_yaml {
|
||||
yamlData, err := yaml.Marshal(&config)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error marshaling to YAML: %s", err)
|
||||
}
|
||||
|
||||
fmt.Println(string(yamlData))
|
||||
} else {
|
||||
prettyJSON, err := json.MarshalIndent(config, "", " ")
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to dump the config file: %s", err)
|
||||
}
|
||||
|
||||
fmt.Println(string(prettyJSON))
|
||||
}
|
||||
|
||||
fmt.Println(string(prettyJSON))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -35,5 +46,6 @@ Example:
|
||||
|
||||
`,
|
||||
}
|
||||
cmd.Flag.Bool("yaml", false, "show yaml config")
|
||||
return cmd
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user