@ -10,7 +10,7 @@ from milc import cli
from qmk.json_encoders import InfoJSONEncoder
from qmk.json_encoders import InfoJSONEncoder
from qmk.constants import COL_LETTERS , ROW_LETTERS
from qmk.constants import COL_LETTERS , ROW_LETTERS
from qmk.decorators import automagic_keyboard , automagic_keymap
from qmk.decorators import automagic_keyboard , automagic_keymap
from qmk.keyboard import keyboard_completer , keyboard_folder , render_layouts , render_layout
from qmk.keyboard import keyboard_completer , keyboard_folder , render_layouts , render_layout , rules_mk
from qmk.keymap import locate_keymap
from qmk.keymap import locate_keymap
from qmk.info import info_json
from qmk.info import info_json
from qmk.path import is_keyboard
from qmk.path import is_keyboard
@ -124,12 +124,20 @@ def print_text_output(kb_info_json):
show_keymap ( kb_info_json , False )
show_keymap ( kb_info_json , False )
def print_parsed_rules_mk ( keyboard_name ) :
rules = rules_mk ( keyboard_name )
for k in sorted ( rules . keys ( ) ) :
print ( ' %s = %s ' % ( k , rules [ k ] ) )
return
@cli.argument ( ' -kb ' , ' --keyboard ' , type = keyboard_folder , completer = keyboard_completer , help = ' Keyboard to show info for. ' )
@cli.argument ( ' -kb ' , ' --keyboard ' , type = keyboard_folder , completer = keyboard_completer , help = ' Keyboard to show info for. ' )
@cli.argument ( ' -km ' , ' --keymap ' , help = ' Show the layers for a JSON keymap too. ' )
@cli.argument ( ' -km ' , ' --keymap ' , help = ' Show the layers for a JSON keymap too. ' )
@cli.argument ( ' -l ' , ' --layouts ' , action = ' store_true ' , help = ' Render the layouts. ' )
@cli.argument ( ' -l ' , ' --layouts ' , action = ' store_true ' , help = ' Render the layouts. ' )
@cli.argument ( ' -m ' , ' --matrix ' , action = ' store_true ' , help = ' Render the layouts with matrix information. ' )
@cli.argument ( ' -m ' , ' --matrix ' , action = ' store_true ' , help = ' Render the layouts with matrix information. ' )
@cli.argument ( ' -f ' , ' --format ' , default = ' friendly ' , arg_only = True , help = ' Format to display the data in (friendly, text, json) (Default: friendly). ' )
@cli.argument ( ' -f ' , ' --format ' , default = ' friendly ' , arg_only = True , help = ' Format to display the data in (friendly, text, json) (Default: friendly). ' )
@cli.argument ( ' --ascii ' , action = ' store_true ' , default = not UNICODE_SUPPORT , help = ' Render layout box drawings in ASCII only. ' )
@cli.argument ( ' --ascii ' , action = ' store_true ' , default = not UNICODE_SUPPORT , help = ' Render layout box drawings in ASCII only. ' )
@cli.argument ( ' -r ' , ' --rules-mk ' , action = ' store_true ' , help = ' Render the parsed values of the keyboard \' s rules.mk file. ' )
@cli.subcommand ( ' Keyboard information. ' )
@cli.subcommand ( ' Keyboard information. ' )
@automagic_keyboard
@automagic_keyboard
@automagic_keymap
@automagic_keymap
@ -146,6 +154,10 @@ def info(cli):
cli . log . error ( ' Invalid keyboard: " %s " ' , cli . config . info . keyboard )
cli . log . error ( ' Invalid keyboard: " %s " ' , cli . config . info . keyboard )
return False
return False
if bool ( cli . args . rules_mk ) :
print_parsed_rules_mk ( cli . config . info . keyboard )
return False
# Build the info.json file
# Build the info.json file
kb_info_json = info_json ( cli . config . info . keyboard )
kb_info_json = info_json ( cli . config . info . keyboard )