Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
tjayrush committed Nov 25, 2024
1 parent 9cc169f commit a690f1d
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 25 deletions.
24 changes: 6 additions & 18 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"fmt"
"strings"

configTypes "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/configtypes"
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output"
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types"
// EXISTING_CODE
Expand All @@ -39,11 +38,11 @@ func (opts *ConfigOptions) ConfigPaths() ([]types.CacheItem, *types.MetaData, er
return queryConfig[types.CacheItem](in)
}

// ConfigSession implements the chifra config --session command.
func (opts *ConfigOptions) ConfigSession() ([]types.Session, *types.MetaData, error) {
// ConfigDump implements the chifra config --dump command.
func (opts *ConfigOptions) ConfigDump() ([]types.Config, *types.MetaData, error) {
in := opts.toInternal()
in.Session = true
return queryConfig[types.Session](in)
in.Dump = true
return queryConfig[types.Config](in)
}

type ConfigMode int
Expand Down Expand Up @@ -97,20 +96,9 @@ func enumFromConfigMode(values []string) (ConfigMode, error) {

// EXISTING_CODE
type ConfigsOptions = ConfigOptions
type SessionsOptions = ConfigOptions

func (opts *ConfigsOptions) ConfigsList() ([]configTypes.Config, *types.MetaData, error) {
meta, err := GetMetaData(opts.Chain)
// the caller is responsible to fill this with the data
return []configTypes.Config{}, meta, err
}

func (opts *SessionsOptions) SessionsList() ([]types.Session, *types.MetaData, error) {
meta, err := GetMetaData(opts.Chain)
// the caller is responsible to fill this with the data
return []types.Session{
{LastChain: ""},
}, meta, err
func (opts *ConfigsOptions) ConfigList() ([]types.Config, *types.MetaData, error) {
return opts.ConfigDump()
}

// EXISTING_CODE
4 changes: 2 additions & 2 deletions config_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
type configOptionsInternal struct {
Mode ConfigMode `json:"mode,omitempty"`
Paths bool `json:"paths,omitempty"`
Session bool `json:"session,omitempty"`
Dump bool `json:"dump,omitempty"`
RenderCtx *output.RenderCtx `json:"-"`
Globals
}
Expand Down Expand Up @@ -85,7 +85,7 @@ func GetConfigOptions(args []string) (*configOptionsInternal, error) {

type configGeneric interface {
types.CacheItem |
types.Session
types.Config
}

func queryConfig[T configGeneric](opts *configOptionsInternal) ([]T, *types.MetaData, error) {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/TrueBlocks/trueblocks-sdk/v3
// Go Version
go 1.22

require github.com/TrueBlocks/trueblocks-core/src/apps/chifra v0.0.0-20241103191228-02c20058347c
require github.com/TrueBlocks/trueblocks-core/src/apps/chifra v0.0.0-20241103193928-2a3d9f89af63

require (
github.com/Microsoft/go-winio v0.6.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migc
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/TrueBlocks/trueblocks-core/src/apps/chifra v0.0.0-20241103191228-02c20058347c h1:ovWX5iJMpegWJZVbj7JFZlseAqwfhvR3lwxyixLfqWY=
github.com/TrueBlocks/trueblocks-core/src/apps/chifra v0.0.0-20241103191228-02c20058347c/go.mod h1:gsyd2/TDvhZ2reZIutMYRoqqhHiFbPG0b4OG1uI+HL8=
github.com/TrueBlocks/trueblocks-core/src/apps/chifra v0.0.0-20241103193928-2a3d9f89af63 h1:+Sinnuci96Ie+kUKiIn5EeUtCunsTTT4au22daUZcDI=
github.com/TrueBlocks/trueblocks-core/src/apps/chifra v0.0.0-20241103193928-2a3d9f89af63/go.mod h1:gsyd2/TDvhZ2reZIutMYRoqqhHiFbPG0b4OG1uI+HL8=
github.com/VictoriaMetrics/fastcache v1.6.0/go.mod h1:0qHz5QP0GMX4pfmMA/zt5RgfNuXJrTP0zS7DqpHGGTw=
github.com/VictoriaMetrics/fastcache v1.12.1 h1:i0mICQuojGDL3KblA7wUNlY5lOK6a4bwt3uRKnkZU40=
github.com/VictoriaMetrics/fastcache v1.12.1/go.mod h1:tX04vaqcNoQeGLD+ra5pU5sWkuxnzWhEzLwhP9w653o=
Expand Down
1 change: 1 addition & 0 deletions python/src/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
configFmt = "json"
configOpts = {
"paths": {"hotkey": "-a", "type": "switch"},
"dump": {"hotkey": "-d", "type": "switch"},
"chain": {"hotkey": "", "type": "flag"},
"noHeader": {"hotkey": "", "type": "switch"},
"fmt": {"hotkey": "-x", "type": "flag"},
Expand Down
5 changes: 3 additions & 2 deletions typescript/src/paths/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@
*/

import * as ApiCallers from '../lib/api_callers';
import { CacheItem, Session } from '../types';
import { CacheItem, Config } from '../types';

export function getConfig(
parameters?: {
mode?: 'show' | 'edit',
paths?: boolean,
dump?: boolean,
fmt?: string,
chain: string,
noHeader?: boolean,
},
options?: RequestInit,
) {
return ApiCallers.fetch<CacheItem[] | Session[]>(
return ApiCallers.fetch<CacheItem[] | Config[]>(
{ endpoint: '/config', method: 'get', parameters, options },
);
}

0 comments on commit a690f1d

Please sign in to comment.