@@ -40,14 +40,26 @@ def set_board():
40
40
usage = "Install CircuitPython board-specific stubs" ,
41
41
)
42
42
parser .add_argument ("chosen_board" , help = "selected board" , nargs = "?" )
43
- parser .add_argument ("-l" , "--list" , help = "show available boards" , action = "store_true" )
43
+ parser .add_argument (
44
+ "-l" ,
45
+ "--list" ,
46
+ help = f"show available boards. can filter eg: '{ __name__ } -l feather'" ,
47
+ action = "store_true" ,
48
+ )
44
49
45
50
args = parser .parse_args ()
46
51
47
52
if args .list :
48
53
port_boards : defaultdict [str , list [str ]] = defaultdict (list )
49
54
50
55
for board in resources .files ("board_definitions" ).iterdir ():
56
+ # if we receive both the list flag and a board name, use it as filter
57
+ if (
58
+ args .chosen_board is not None
59
+ and args .chosen_board .lower () not in board .name .lower ()
60
+ ):
61
+ continue
62
+
51
63
# NOTE: For the hand-crafted finding of port in the docstring, its
52
64
# format is assumed to be:
53
65
#
@@ -65,6 +77,10 @@ def set_board():
65
77
66
78
port_boards [port ].append (board .name )
67
79
80
+ if not port_boards :
81
+ sys .stdout .write ("Nothing found, check out your filter.\n " )
82
+ sys .exit (0 )
83
+
68
84
sys .stdout .write ("Available boards are: \n " )
69
85
# sort by port name
70
86
for port , boards in sorted (port_boards .items (), key = lambda kv : kv [0 ]):
0 commit comments