@@ -40,14 +40,26 @@ def set_board():
4040 usage = "Install CircuitPython board-specific stubs" ,
4141 )
4242 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+ )
4449
4550 args = parser .parse_args ()
4651
4752 if args .list :
4853 port_boards : defaultdict [str , list [str ]] = defaultdict (list )
4954
5055 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+
5163 # NOTE: For the hand-crafted finding of port in the docstring, its
5264 # format is assumed to be:
5365 #
@@ -65,6 +77,10 @@ def set_board():
6577
6678 port_boards [port ].append (board .name )
6779
80+ if not port_boards :
81+ sys .stdout .write ("Nothing found, check out your filter.\n " )
82+ sys .exit (0 )
83+
6884 sys .stdout .write ("Available boards are: \n " )
6985 # sort by port name
7086 for port , boards in sorted (port_boards .items (), key = lambda kv : kv [0 ]):
0 commit comments