blob: 9b3bd35c86d4bd6b034c34f72cff7f34be8897e0 [file] [log] [blame]
Chris Luke90f52bf2016-09-12 08:55:13 -04001# Copyright (c) 2016 Comcast Cable Communications Management, LLC.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at:
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15# Generate clicmd formatted output
16
17import process, parsers
18
19class SiphonCLICMD(process.Siphon):
20
21 name = "clicmd"
22 identifier = "VLIB_CLI_COMMAND"
23
24 def __init__(self, *args, **kwargs):
25 super(SiphonCLICMD, self).__init__(*args, **kwargs)
26 self._parser = parsers.MacroInitializer()
27
28
29 # Output renderers
30
31 def index_sort_key(self, group):
32 _global = self._cmds['_global']
33 if group not in self._group:
34 return group
35 (directory, file) = self._group[group]
36
37 if file in _global and 'group_label' in _global[file]:
38 return _global[file]['group_label']
39
40 if directory in _global and 'group_label' in _global[directory]:
41 return _global[directory]['group_label']
42
43 return group
44
45 def item_sort_key(self, item):
46 return item['value']['path']
47
48 def item_label(self, group, item):
49 return "_".join((
50 self.name,
51 self.sanitize_label(self._cmds[group][item]['value']['path'])
52 ))
53
54
55# Register our processor
56process.siphons["clicmd"] = SiphonCLICMD