Skip to content

Commit 1f366f9

Browse files
saurabhkpateldbieber
authored andcommitted
Bug Fix : name was not setting if command is set (google#65)
* default name was not used when a command was provided
1 parent d998200 commit 1f366f9

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

fire/core.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,13 @@ def Fire(component=None, command=None, name=None):
101101
# Get args as a list.
102102
if command is None:
103103
# Use the command line args by default if no command is specified.
104-
name = name or os.path.basename(sys.argv[0])
105104
args = sys.argv[1:]
106105
else:
107106
# Otherwise use the specified command.
108107
args = shlex.split(command)
109108

109+
name = name or os.path.basename(sys.argv[0])
110+
110111
# Determine the calling context.
111112
caller = inspect.stack()[1]
112113
caller_frame = caller[0]

fire/fire_test.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,9 @@ def testHelpFlagAndTraceFlag(self):
324324
fire.Fire(tc.BoolConverter, '-- -h --trace')
325325

326326
def testTabCompletionNoName(self):
327-
with self.assertRaises(ValueError):
328-
fire.Fire(tc.NoDefaults, '-- --completion')
327+
completion_script = fire.Fire(tc.NoDefaults, '-- --completion')
328+
self.assertIn('double', completion_script)
329+
self.assertIn('triple', completion_script)
329330

330331
def testTabCompletion(self):
331332
completion_script = fire.Fire(tc.NoDefaults, '-- --completion', name='c')

0 commit comments

Comments
 (0)