MCPcopy Create free account
hub / github.com/NetSys/bess / find_cmd

Method find_cmd

bessctl/cli.py:352–375  ·  view source on GitHub ↗
(self, line)

Source from the content-addressed store, hash-verified

350 return '> '
351
352 def find_cmd(self, line):
353 # return commands being matched with every token
354 matched, matched_low = self.list_matched(line, 'full')
355 line_stripped = line.strip()
356
357 if len(matched) == 1:
358 return matched[0]
359
360 elif len(matched) >= 2:
361 self.err('Ambiguous command "%s". Candidates:' % line_stripped)
362 for cmd, desc, _ in matched + matched_low:
363 self.ferr.write(' %-50s%s\n' % (cmd, desc))
364
365 elif len(matched) == 0:
366 matched, matched_low = self.list_matched(line, 'partial')
367 if len(matched) > 0:
368 self.err('Incomplete command "%s". Candidates:' %
369 line_stripped)
370 for cmd, desc, _ in matched + matched_low:
371 self.ferr.write(' %-50s%s\n' % (cmd, desc))
372 else:
373 self.err('Unknown command "%s".' % line_stripped)
374
375 raise self.InvalidCommandError()
376
377 def get_default_args(self):
378 return []

Callers 1

process_one_lineMethod · 0.95

Calls 2

list_matchedMethod · 0.95
errMethod · 0.95

Tested by

no test coverage detected