def cmd_which(view, edit, args, wd, rkey): l = [] am = aliases() m = builtins() if not args: args = [] args.extend(sorted(m.keys())) args.extend(sorted(am.keys())) fm = '%{0}s: %s'.format(max(len(s) for s in args)) for k in args: if k == 'sh': v = '9o builtin: %s' % sh.cmd('${CMD}') elif k in ('go'): v = '9o builtin: %s' % sh.which(k) elif k in m: v = '9o builtin' elif k in am: v = '9o alias: `%s`' % am[k] else: v = sh.which(k) l.append(fm % (k, v)) push_output(view, rkey, '\n'.join(l))
def cmd_which(view, edit, args, wd, rkey): l = [] am = aliases() m = builtins() if not args: args = [] args.extend(sorted(m.keys())) args.extend(sorted(am.keys())) fm = "%{0}s: %s".format(max(len(s) for s in args)) for k in args: if k == "sh": v = "9o builtin: %s" % sh.cmd("${CMD}") elif k in ("go"): v = "9o builtin: %s" % sh.which(k) elif k in m: v = "9o builtin" elif k in am: v = "9o alias: `%s`" % am[k] else: v = sh.which(k) l.append(fm % (k, v)) push_output(view, rkey, "\n".join(l))
def sanity_check(env={}, error_log=False): if not env: env = sh.env() ns = '(not set)' sl = [ ('install state', _inst_state()), ('sublime.version', sublime.version()), ('sublime.channel', sublime.channel()), ('about.ann', gs.attr('about.ann', '')), ('about.version', gs.attr('about.version', '')), ('version', about.VERSION), ('platform', about.PLATFORM), ('~bin', '%s' % sh.bin_dir()), ('go.exe', '%s (%s)' % _tp(sh.which('go') or 'go')), ('margo.exe', '%s (%s)' % _tp(sh.which('margo') or 'margo')), ('go.version', sh.GO_VERSION), ('GOROOT', '%s' % env.get('GOROOT', ns)), ('GOPATH', '%s' % env.get('GOPATH', ns)), ('GOBIN', env.get('GOBIN', ns)), ('set.shell', str(gs.lst(gs.setting('shell')))), ('env.shell', env.get('SHELL', '')), ('shell.cmd', str(sh.cmd('${CMD}'))), ] if error_log: try: with open(gs.home_path('log.txt'), 'r') as f: s = f.read().strip() sl.append(('error log', s)) except Exception: pass return sl
def sanity_check(env={}, error_log=False): if not env: env = sh.env() ns = '(not set)' sl = [ ('install state', _inst_state()), ('sublime.version', sublime.version()), ('sublime.channel', sublime.channel()), ('about.ann', gs.attr('about.ann', '')), ('about.version', gs.attr('about.version', '')), ('version', about.VERSION), ('platform', about.PLATFORM), ('~bin', '%s' % gs.home_dir_path('bin')), ('margo.exe', '%s (%s)' % _tp(_margo_bin())), ('go.exe', '%s (%s)' % _tp(sh.which('go') or 'go')), ('go.version', sh.GO_VERSION), ('GOROOT', '%s' % env.get('GOROOT', ns)), ('GOPATH', '%s' % env.get('GOPATH', ns)), ('GOBIN', '%s (should usually be `%s`)' % (env.get('GOBIN', ns), ns)), ('set.shell', str(gs.lst(gs.setting('shell')))), ('env.shell', env.get('SHELL', '')), ('shell.cmd', str(sh.cmd('${CMD}'))), ] if error_log: try: with open(gs.home_path('log.txt'), 'r') as f: s = f.read().strip() sl.append(('error log', s)) except Exception: pass return sl
def oracle(self, end_offset, begin_offset=None, mode="plain", scope=""): """ Builds the oracle shell command and calls it, returning it's output as a string. """ file_path = self.view.file_name() output_format = "plain" pos = "#" + str(end_offset) if begin_offset is not None: pos = "#%i,#%i" % (begin_offset, end_offset) oracle = sh.which("oracle") if oracle: args = [ "-pos=" + file_path + ":" + pos, "-format=" + output_format, mode ] if scope: args.append(scope) shcmd = gs.lst(oracle, args) print(" ".join(shcmd)) cmd = sh.Command(shcmd) cr = cmd.run() if cr.exc: _print('error loading env vars: %s' % cr.exc) return cr.out, cr.err return
def sanity_check(env={}, error_log=False): if not env: env = sh.env() ns = "(not set)" sl = [ ("install state", _inst_state()), ("sublime.version", sublime.version()), ("sublime.channel", sublime.channel()), ("about.ann", gs.attr("about.ann", "")), ("about.version", gs.attr("about.version", "")), ("version", about.VERSION), ("platform", about.PLATFORM), ("~bin", "%s" % gs.home_dir_path("bin")), ("margo.exe", "%s (%s)" % _tp(_margo_bin())), ("go.exe", "%s (%s)" % _tp(sh.which("go") or "go")), ("go.version", sh.GO_VERSION), ("GOROOT", "%s" % env.get("GOROOT", ns)), ("GOPATH", "%s" % env.get("GOPATH", ns)), ("GOBIN", "%s (should usually be `%s`)" % (env.get("GOBIN", ns), ns)), ("set.shell", str(gs.lst(gs.setting("shell")))), ("env.shell", env.get("SHELL", "")), ("shell.cmd", str(sh.cmd("${CMD}"))), ] if error_log: try: with open(gs.home_path("log.txt"), "r") as f: s = f.read().strip() sl.append(("error log", s)) except Exception: pass return sl
def _mg_exists(): return bool(sh.which('margo'))