Skip to content

Commit

Permalink
Updates config help files
Browse files Browse the repository at this point in the history
  • Loading branch information
tjayrush committed Dec 17, 2024
1 parent c75bfc0 commit d3f686a
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/apps/chifra/internal/config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Arguments:
Flags:
-a, --paths show the configuration paths for the system
-d, --dump dump the configuration to stdout
-x, --fmt string export format, one of [none|json*|txt|csv]
-v, --verbose enable verbose output
-h, --help display this help screen
Expand Down
2 changes: 1 addition & 1 deletion src/apps/chifra/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func pathFromXDG(envVar string) (string, error) {
absXDGPath, err := filepath.Abs(xdg)
if err != nil {
return "", usage.Usage("The {0} value ({1}), could not be interpreted as an absolute path.", envVar, xdg)
}
}

if _, err := os.Stat(absXDGPath); err != nil {
return "", usage.Usage("The {0} folder ({1}) must exist.", envVar, absXDGPath)
Expand Down
53 changes: 53 additions & 0 deletions src/apps/chifra/pkg/types/types_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved.
// Use of this source code is governed by a license that can
// be found in the LICENSE file.
package types

import (
"encoding/json"

"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/configtypes"
)

type Config struct {
Version configtypes.VersionGroup `json:"version" toml:"version"`
Settings configtypes.SettingsGroup `json:"settings" toml:"settings"`
Keys map[string]configtypes.KeyGroup `json:"keys" toml:"keys"`
Pinning configtypes.PinningGroup `json:"pinning" toml:"pinning"`
Unchained configtypes.UnchainedGroup `json:"unchained" toml:"unchained,omitempty" comment:"Do not edit these values unless instructed to do so."`
Chains map[string]configtypes.ChainGroup `json:"chains" toml:"chains"`
}

func (s Config) String() string {
bytes, _ := json.Marshal(s)
return string(bytes)
}

func (s *Config) Model(chain, format string, verbose bool, extraOpts map[string]any) Model {
// keys := map[string]any{}
// for key, value := range s.Keys {
// keys[key] = value
// }
c := map[string]any{}
for key, value := range s.Chains {
c[key] = value
}
return Model{
Data: map[string]any{
"version": s.Version,
"settings": s.Settings,
"keys": s.Keys,
"pinnging": s.Pinning,
"unchained": s.Unchained,
"chains": s.Chains,
},
Order: []string{},
}
}

func (s *Config) FinishUnmarshal() {
}

func (s *Config) ShallowCopy() Config {
return *s
}
6 changes: 3 additions & 3 deletions src/dev_tools/sdkFuzzer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ func TestConfig(which, value, fn string, opts *sdk.ConfigOptions) {
ReportOkay(fn)
}
}
case "session":
if session, _, err := opts.ConfigSession(); err != nil {
case "dump":
if dump, _, err := opts.ConfigDump(); err != nil {
ReportError(fn, opts, err)
} else {
if err := SaveToFile[types.Session](fn, session); err != nil {
if err := SaveToFile[types.Config](fn, dump); err != nil {
ReportError2(fn, err)
} else {
ReportOkay(fn)
Expand Down

0 comments on commit d3f686a

Please sign in to comment.