File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change 4
4
5
5
from noid import utils , cli
6
6
7
+ # make exit codes cross-platform
8
+ SUCCESS_EXIT_CODE = getattr (os , 'EX_OK' , 0 )
9
+ USAGE_EXIT_CODE = getattr (os , 'EX_USAGE' , 64 )
7
10
8
11
def mint (template : str = 'zek' , n : int = - 1 , scheme : str = '' , naa : str = '' ) -> str :
9
12
""" Mint identifiers according to template with a prefix of scheme + naa.
@@ -148,7 +151,7 @@ def main():
148
151
"""Main entry point"""
149
152
args = cli .parse_args ()
150
153
if args is None :
151
- return os . EX_USAGE
154
+ return USAGE_EXIT_CODE
152
155
if args .validate :
153
156
if args .verbose :
154
157
print (f"info: validating '{ args .noid } '..." , file = sys .stderr )
@@ -164,7 +167,7 @@ def main():
164
167
f"scheme={ args .scheme } , naa={ args .naa } ..." , file = sys .stderr )
165
168
noid = mint (args .template , args .index , scheme = args .scheme , naa = args .naa )
166
169
print (noid )
167
- return os . EX_OK
170
+ return SUCCESS_EXIT_CODE
168
171
169
172
170
173
if __name__ == '__main__' :
Original file line number Diff line number Diff line change @@ -179,10 +179,11 @@ def test_default(self):
179
179
self .assertRegex (sys .stdout .getvalue (), r"(?ms:^info: generating noid.*template=.*scheme=.*ark[:][/][\w\d]+)" )
180
180
181
181
def test_error (self ):
182
- """Exit status on *nix is os.EX_USAGE"""
182
+ """Exit status on *nix is os.EX_USAGE, but its not available on Windows"""
183
+ USAGE_EXIT_CODE = getattr (os , 'EX_USAGE' , 64 )
183
184
cli .cli (f"noid -V" )
184
185
ex = pynoid .main ()
185
- self .assertEqual (os . EX_USAGE , ex )
186
+ self .assertEqual (USAGE_EXIT_CODE , ex )
186
187
187
188
def test_config (self ):
188
189
"""Using config"""
You can’t perform that action at this time.
0 commit comments