Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Commit 88db48c

Browse files
committed
cleanup of logic around uuid match. added support for dashes/underscores in commands
1 parent ca858f6 commit 88db48c

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

cli4/cli4.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def run_command(cf, method, command, params=None, content=None, files=None):
6262
if len(element) in [32, 40, 48] and hex_only.match(element):
6363
# raw identifier - lets just use it as-is
6464
identifier1 = element
65-
if len(element) == 36 and uuid_value.match(element):
65+
elif len(element) == 36 and uuid_value.match(element):
6666
# uuid identifier - lets just use it as-is
6767
identifier1 = element
6868
elif element[0] == ':':
@@ -97,7 +97,7 @@ def run_command(cf, method, command, params=None, content=None, files=None):
9797
if len(element) in [32, 40, 48] and hex_only.match(element):
9898
# raw identifier - lets just use it as-is
9999
identifier2 = element
100-
if len(element) == 36 and uuid_value.match(element):
100+
elif len(element) == 36 and uuid_value.match(element):
101101
# uuid identifier - lets just use it as-is
102102
identifier2 = element
103103
elif element[0] == ':':
@@ -128,11 +128,14 @@ def run_command(cf, method, command, params=None, content=None, files=None):
128128
if len(element) in [32, 40, 48] and hex_only.match(element):
129129
# raw identifier - lets just use it as-is
130130
identifier3 = element
131-
if len(element) == 36 and uuid_value.match(element):
131+
elif len(element) == 36 and uuid_value.match(element):
132132
# uuid identifier - lets just use it as-is
133133
identifier3 = element
134134
elif waf_rules.match(element):
135135
identifier3 = element
136+
elif element[0] == ':':
137+
# raw string - used for workers script_names
138+
identifier3 = element[1:]
136139
else:
137140
if len(cmd) >= 6 and cmd[0] == 'accounts' and cmd[2] == 'storage' and cmd[3] == 'kv' and cmd[4] == 'namespaces' and cmd[6] == 'values':
138141
identifier3 = element
@@ -141,7 +144,11 @@ def run_command(cf, method, command, params=None, content=None, files=None):
141144
raise e
142145
else:
143146
try:
144-
m = getattr(m, element)
147+
# dashes (vs underscores) cause issues in Python and other languages
148+
if '-' in element:
149+
m = getattr(m, element.replace('-','_'))
150+
else:
151+
m = getattr(m, element)
145152
cmd.append(element)
146153
except AttributeError:
147154
# the verb/element was not found

0 commit comments

Comments
 (0)