<commit_before>
use "files"

actor Main
  let env: Env
  let log: Log
  
  new create(env': Env) =>
    env = env'
    log = LogSimple(env.err)
    
    command(try env.args(1) else "" end, env.args.slice(2))
  
  fun _print_usage() =>
    env.out.printv(recover [
      "Usage: stable COMMAND [...]",
      "",
      "    A simple dependency manager for the Pony language.",
      "",
      "    Invoke in a working directory containing a bundle.json.",
      "",
      "Commands:",
      "    help  - Print this message",
      "    fetch - Fetch/update the deps for this bundle",
      "    env   - Execute the following shell command inside an environment",
      "            with PONYPATH set to include deps directories. For example,",
      "            `stable env ponyc myproject`",
      "    add   - Add a new dependency. For exemple,",
      "            `stable add github jemc/pony-inspect",
    ""] end)
  
  fun _load_bundle(create_on_missing: Bool = false): Bundle? =>
    let cwd = Path.cwd()
    var path = cwd
    while path.size() > 0 do
      try
        return Bundle(FilePath(env.root as AmbientAuth, path), log, false)
      else
        path = Path.split(path)._1
      end
    end
    if create_on_missing then
      Bundle(FilePath(env.root as AmbientAuth, cwd), log, true)
    else
      log("No bundle.json in current working directory or ancestors.")
      error
    end
  
  fun command("fetch", _) =>
    try _load_bundle().fetch() end
  
  fun command("env", rest: Array[String] box) =>
    let ponypath = try let bundle = _load_bundle()
      var ponypath' = recover trn String end
      let iter = bundle.paths().values()
      for path in iter do
        ponypath'.append(path)
        if iter.has_next() then ponypath'.push(':') end
      end
      
      ponypath'
    else
      ""
    end
    try
      Shell.from_array(
        ["env", "PONYPATH="+ponypath].>append(rest), env~exitcode()<commit_msg>FIX compile with pony 0.12 Arrays as sequences (#18)<commit_after>
use "files"

actor Main
  let env: Env
  let log: Log
  
  new create(env': Env) =>
    env = env'
    log = LogSimple(env.err)
    
    command(try env.args(1) else "" end, env.args.slice(2))
  
  fun _print_usage() =>
    env.out.printv(recover [
      "Usage: stable COMMAND [...]"
      ""
      "    A simple dependency manager for the Pony language."
      ""
      "    Invoke in a working directory containing a bundle.json."
      ""
      "Commands:"
      "    help  - Print this message"
      "    fetch - Fetch/update the deps for this bundle"
      "    env   - Execute the following shell command inside an environment"
      "            with PONYPATH set to include deps directories. For example,"
      "            `stable env ponyc myproject`"
      "    add   - Add a new dependency. For exemple,"
      "            `stable add github jemc/pony-inspect"
    ""] end)
  
  fun _load_bundle(create_on_missing: Bool = false): Bundle? =>
    let cwd = Path.cwd()
    var path = cwd
    while path.size() > 0 do
      try
        return Bundle(FilePath(env.root as AmbientAuth, path), log, false)
      else
        path = Path.split(path)._1
      end
    end
    if create_on_missing then
      Bundle(FilePath(env.root as AmbientAuth, cwd), log, true)
    else
      log("No bundle.json in current working directory or ancestors.")
      error
    end
  
  fun command("fetch", _) =>
    try _load_bundle().fetch() end
  
  fun command("env", rest: Array[String] box) =>
    let ponypath = try let bundle = _load_bundle()
      var ponypath' = recover trn String end
      let iter = bundle.paths().values()
      for path in iter do
        ponypath'.append(path)
        if iter.has_next() then ponypath'.push(':') end
      end
      
      ponypath'
    else
      ""
    end
    try
      Shell.from_array(
        ["env"; "PONYPATH="+ponypath].>append(rest), env~exitcode()
{'fraction_non_alphanumeric': 0.11204911742133537, 'fraction_numerical': 0.00332565873624968, 'mean_word_length': 2.098256735340729, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '1306708', 'n_tokens_mistral': 1237, 'n_tokens_neox': 1212, 'n_words': 375}