mirror of
https://github.com/aljazceru/ark.git
synced 2025-12-17 20:24:21 +01:00
[CLI] Fix init checks (#314)
* empty config check & version flag support * fix: empty config check & version flag support (#309) * fix * cli init check Prevent execution without initialization by checking cfgData and returning error if not initialized * merge with master * Replace errors.New with fmt.Errorf Signed-off-by: Pietralberto Mazza <18440657+altafan@users.noreply.github.com> --------- Signed-off-by: Pietralberto Mazza <18440657+altafan@users.noreply.github.com> Co-authored-by: Pietralberto Mazza <18440657+altafan@users.noreply.github.com>
This commit is contained in:
@@ -221,10 +221,6 @@ func config(ctx *cli.Context) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if cfgData == nil {
|
||||
fmt.Println("no configuration found, run 'init' command")
|
||||
return nil
|
||||
}
|
||||
|
||||
cfg := map[string]interface{}{
|
||||
"asp_url": cfgData.AspUrl,
|
||||
@@ -388,6 +384,12 @@ func getArkSdkClient(ctx *cli.Context) (arksdk.ArkClient, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
commandName := ctx.Args().First()
|
||||
if commandName != "init" && cfgData == nil {
|
||||
return nil, fmt.Errorf("CLI not initialized, run 'init' cmd to initialize")
|
||||
}
|
||||
|
||||
net := getNetwork(ctx, cfgData)
|
||||
|
||||
if isBtcChain(net) {
|
||||
|
||||
Reference in New Issue
Block a user