mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'feature/idfpy_hidden_commands' into 'master'
idf.py: add support for subcommands hidden from help See merge request espressif/esp-idf!6646
This commit is contained in:
commit
83b468f707
@ -195,11 +195,13 @@ def init_cli(verbose_output=None):
|
||||
deprecated=False,
|
||||
dependencies=None,
|
||||
order_dependencies=None,
|
||||
hidden=False,
|
||||
**kwargs):
|
||||
super(Action, self).__init__(name, **kwargs)
|
||||
|
||||
self.name = self.name or self.callback.__name__
|
||||
self.deprecated = deprecated
|
||||
self.hidden = hidden
|
||||
|
||||
if aliases is None:
|
||||
aliases = []
|
||||
@ -405,7 +407,7 @@ def init_cli(verbose_output=None):
|
||||
self._actions[name].params.append(option)
|
||||
|
||||
def list_commands(self, ctx):
|
||||
return sorted(self._actions)
|
||||
return sorted(filter(lambda name: not self._actions[name].hidden, self._actions))
|
||||
|
||||
def get_command(self, ctx, name):
|
||||
return self._actions.get(self.commands_with_aliases.get(name))
|
||||
|
@ -20,5 +20,9 @@ def action_extensions(base_actions, project_path=os.getcwd()):
|
||||
"callback": test_callback,
|
||||
"help": "Help for test subcommand.",
|
||||
},
|
||||
},
|
||||
"hidden_one": {
|
||||
"callback": test_callback,
|
||||
"hidden": True
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -65,6 +65,18 @@ class TestExtensions(unittest.TestCase):
|
||||
finally:
|
||||
os.remove(link_path)
|
||||
|
||||
def test_hidden_commands(self):
|
||||
try:
|
||||
os.symlink(extension_path, link_path)
|
||||
os.environ["IDF_EXTRA_ACTIONS_PATH"] = ";".join([os.path.join(current_dir, 'extra_path')])
|
||||
output = subprocess.check_output([sys.executable, idf_py_path, "--help"],
|
||||
env=os.environ).decode('utf-8', 'ignore')
|
||||
self.assertIn('test_subcommand', output)
|
||||
self.assertNotIn('hidden_one', output)
|
||||
|
||||
finally:
|
||||
os.remove(link_path)
|
||||
|
||||
|
||||
class TestDependencyManagement(unittest.TestCase):
|
||||
def test_dependencies(self):
|
||||
|
Loading…
Reference in New Issue
Block a user