<commit_before>import sys
import config
import json

from restnavigator import Navigator

usage = """Usage:
   
- huck create <cliname> to alias into a new cli. Restarting the terminal
  is required since we're using a .bash_profile alias.
                   
- huck cli <cliname> to invoke a cli. Note that the <cliname> alias created with
  huck create <cliname> should be used instead, for brevity.
"""

def navigate(argv):
    h = Navigator.hal(config.url, apiname=config.cliname)

    if len(argv) == 1:
      print json.dumps(h(), indent=4, sort_keys=True)

    length = len(argv[1:])
    for i, x in enumerate(argv[1:]):
        try:
            h.links["command"].get_by("name", x)
        except:
            print "ERROR: The \"" + x + "\" command is not available."
            break

        if i == length - 1:
          print json.dumps(h(), indent=4, sort_keys=True)

def cli():
    if len(sys.argv) > 2:
        if sys.argv[1] == "cli":
            config.parse_configuration(sys.argv[2])<commit_msg>fix navigation via the rest navigator and error out if we can't navigate commands<commit_after>import sys
import config
import json

from restnavigator import Navigator

usage = """Usage:
   
- huck create <cliname> to alias into a new cli. Restarting the terminal
  is required since we're using a .bash_profile alias.
                   
- huck cli <cliname> to invoke a cli. Note that the <cliname> alias created with
  huck create <cliname> should be used instead, for brevity.
"""

def navigate(argv):
    h = Navigator.hal(config.url, apiname=config.cliname)
    if len(argv) == 1:
      print json.dumps(h(), indent=4, sort_keys=True)

    length = len(argv[1:])
    for i, x in enumerate(argv[1:]):
        h = h["command"].get_by("name", x)
        if h is None:
            print "ERROR: The \"" + x + "\" command is not available."
            break

        if i == length - 1:
          print json.dumps(h(), indent=4, sort_keys=True)

def cli():
    if len(sys.argv) > 2:
        if sys.argv[1] == "cli":
            config.parse_configuration(sys.argv[2])
{'fraction_non_alphanumeric': 0.12080536912751678, 'fraction_numerical': 0.00862895493767977, 'mean_word_length': 2.561433447098976, 'pattern_counts': {'":': 2, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2298957', 'n_tokens_mistral': 695, 'n_tokens_neox': 660, 'n_words': 223}