Fork me on GitHub

Usage

plash list-macros [ MACROLIB ]

Description

Lists all available macros. Pass a macro library as first parameter to list
macros defined there.

Tested behaviour

Preface


    
  
    
      

Output contain some macros


    
  
    
      
plash help-macros | grep run
plash help-macros | grep layer
plash help-macros | grep run-stdin

Source Code

import sys

from plash.eval import MacroError, eval, get_macros
from plash import utils

try:
    import_macros = sys.argv[1]
except IndexError:
    import_macros = "plash.macros.all"

with utils.catch_and_die([MacroError]):
    eval([["import", import_macros]])

macros = get_macros()
prev_group = None
for name, func in sorted(macros.items(), key=lambda i: (i[1].__module__, i[0])):
    group = func.__module__
    if group != prev_group:
        prev_group is None or print()
        print("[{}]".format(group))
    print("{: <16} = {}".format(name, func.__doc__))
    prev_group = group