5
5
# Made by Humans from OpenPeeps
6
6
# https://github.com/openpeeps/kapsis
7
7
8
- import std/ [macros, macrocache, os, times, tables,
9
- strutils, sequtils, parseopt, json, oids, enumutils,
10
- uri]
8
+ import std/ [macros, os, times, tables,
9
+ strutils, sequtils, parseopt, json,
10
+ oids, enumutils, uri]
11
11
12
12
import pkg/ [voodoo, jsony, checksums/ md5]
13
13
@@ -673,30 +673,30 @@ macro commands*(registeredCommands: untyped, extras: untyped = nil) =
673
673
Kapsis .mainCommand = Kapsis .commands[`kapsisSettings`.mainCommandId]
674
674
var
675
675
p = quoteShellCommand (commandLineParams ()).initOptParser
676
- id : KapsisInput
676
+ kapsisCommandId : KapsisInput
677
677
input = p.getopt.toSeq ()
678
678
defaultCommand = Kapsis .mainCommand != nil
679
679
if input.len == 0 :
680
680
printUsage ()
681
681
QuitSuccess .quit
682
682
if Kapsis .commands.hasKey (input[0 ].key) == false and defaultCommand:
683
- id = (cmdArgument, Kapsis .mainCommand.id, " " )
683
+ kapsisCommandId = (cmdArgument, Kapsis .mainCommand.id, " " )
684
684
else :
685
- id = input[0 ]
686
- input .delete (0 )
685
+ kapsisCommandId = input[0 ]
686
+ sequtils .delete (input, 0 , 0 )
687
687
var values = ValuesTable ()
688
- case id .kind
688
+ case kapsisCommandId .kind
689
689
of cmdArgument:
690
- if likely (Kapsis .commands.hasKey (id .key)):
691
- let cmd: KapsisCommand = Kapsis .commands[id .key]
690
+ if likely (Kapsis .commands.hasKey (kapsisCommandId .key)):
691
+ let cmd: KapsisCommand = Kapsis .commands[kapsisCommandId .key]
692
692
var i = 0
693
693
var flagpos: seq [int ]
694
694
while i <= input.high:
695
695
case input[i].kind
696
696
of cmdLongOption, cmdShortOption:
697
697
if input[i].key in [" help" , " h" ]:
698
698
# print helpers of a specific command
699
- printUsage (showExtras= false , showCommand= id .key)
699
+ printUsage (showExtras= false , showCommand= kapsisCommandId .key)
700
700
QuitSuccess .quit
701
701
else :
702
702
let key = prefix (input[i].key, input[i].kind)
@@ -721,7 +721,7 @@ macro commands*(registeredCommands: untyped, extras: untyped = nil) =
721
721
# input.delete(x) # delete flags
722
722
for i in 0 .. index.high:
723
723
if i in flagpos:
724
- echo " flag"
724
+ # echo "flag"
725
725
continue
726
726
if index[i][0 ] in {cmdLongOption, cmdShortOption}:
727
727
continue # already collected, skipping flags
@@ -749,16 +749,16 @@ macro commands*(registeredCommands: untyped, extras: untyped = nil) =
749
749
# instead, will list the available subcommands.
750
750
printUsage (false , cmd.idDir, true )
751
751
else : discard
752
- else : printError (unknownCommand, id .key)
752
+ else : printError (unknownCommand, kapsisCommandId .key)
753
753
of cmdLongOption, cmdShortOption:
754
754
# print usage including argument types.
755
755
# -v/--version prints the current version
756
756
# of the application that is automatically
757
757
# retrieved from your .nimble file
758
- case id .key
758
+ case kapsisCommandId .key
759
759
of " help" , " h" : printUsage (showExtras = true )
760
760
of " version" , " v" : display (Kapsis .pkg.version)
761
- else : printError (unknownOption, id .key)
761
+ else : printError (unknownOption, kapsisCommandId .key)
762
762
else : discard
763
763
add result , blockStmt
764
764
# echo result.repr
0 commit comments