def __init__(self, name, make_task): self.name = name self.conf_path = os.path.join( os.path.dirname(sys.argv[0]), "%ss.conf" % self.name) self.make_task = make_task if self.conf_exists(): engine.add_reloader(self.conf_path, self.load) self.load()
def load(open_path, task_name=None, pre_hook=None): if not os.path.exists(open_path): return with open(open_path) as conf: try: commands = json.load(conf) except ValueError: sys.stderr.write("Warning: invalid JSON at {}".format(open_path)) return engine.add_reloader(open_path, full_reload) [add_command(command, pre_hook) for command in commands] if task_name: engine.add(prompt_and_save(open_path), task_name)
from commander import command from commander import engine from commander.helpers import expand_path from commander.helpers import noclear from commander.helpers import run from commander.helpers import split import commander conf_path = join( os.path.dirname(os.path.realpath(__file__)), "mycommands-conf.json") with open(conf_path) as confFile: conf = json.load(confFile) engine.add_reloader(conf_path, commander.full_reload) ACTIVE_PROJECT = expand_path("~/.active_project") projects = { "fp": "FootprintID", "gl": "GorillaLogic", "sp": "Small Planet" } def project_specific_browser(command): if "app" in command: return arg = command.get("args", [""])[0] if not arg.startswith("http"): return