github.com/TrueBlocks/trueblocks-core/src/apps/chifra@v0.0.0-20241022031540-b362680128f7/cmd/config.go (about) 1 // Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 // Use of this source code is governed by a license that can 3 // be found in the LICENSE file. 4 /* 5 * Parts of this file were auto generated. Edit only those parts of 6 * the code inside of 'EXISTING_CODE' tags. 7 */ 8 9 package cmd 10 11 // EXISTING_CODE 12 import ( 13 "os" 14 15 configPkg "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/internal/config" 16 "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/internal/globals" 17 "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/caps" 18 "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/file" 19 outputHelpers "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output/helpers" 20 "github.com/spf13/cobra" 21 ) 22 23 // EXISTING_CODE 24 25 // configCmd represents the config command 26 var configCmd = &cobra.Command{ 27 Use: usageConfig, 28 Long: longConfig, 29 Version: versionText, 30 PreRun: outputHelpers.PreRunWithJsonWriter("config", func() *globals.GlobalOptions { 31 return &configPkg.GetOptions().Globals 32 }), 33 RunE: file.RunWithFileSupport("config", configPkg.RunConfig, configPkg.ResetOptions), 34 PostRun: outputHelpers.PostRunWithJsonWriter(func() *globals.GlobalOptions { 35 return &configPkg.GetOptions().Globals 36 }), 37 } 38 39 const usageConfig = `config <mode> [flags] 40 41 Arguments: 42 mode - either show or edit the configuration 43 One of [ show | edit ]` 44 45 const longConfig = `Purpose: 46 Report on and edit the configuration of the TrueBlocks system.` 47 48 const notesConfig = `` 49 50 func init() { 51 var capabilities caps.Capability // capabilities for chifra config 52 capabilities = capabilities.Add(caps.Default) 53 54 configCmd.Flags().SortFlags = false 55 56 configCmd.Flags().BoolVarP(&configPkg.GetOptions().Paths, "paths", "a", false, `show the configuration paths for the system`) 57 globals.InitGlobals("config", configCmd, &configPkg.GetOptions().Globals, capabilities) 58 59 configCmd.SetUsageTemplate(UsageWithNotes(notesConfig)) 60 configCmd.SetOut(os.Stderr) 61 62 // EXISTING_CODE 63 // EXISTING_CODE 64 65 chifraCmd.AddCommand(configCmd) 66 }