// cell help - Display help information for cell commands

var io = use('io')

var command = args.length > 0 ? args[0] : null

// Display specific command help
if (command) {
  var man_file = 'scripts/man/' + command + '.man'
  if (io.exists(man_file)) {
    var content = io.slurp(man_file)
    log.console(content)
  } else {
    log.error("No help available for command: " + command)
    log.console("Run 'cell help' to see available commands.")
  }
  $_.stop()
  return
}

// Display general help
var cell_man = 'scripts/man/cell.man'
if (io.exists(cell_man)) {
  var content = io.slurp(cell_man)
  log.console(content)
} else {
  // Fallback if man file doesn't exist
  log.console("cell - The Cell module system for Prosperon")
  log.console("")
  log.console("Usage: cell <command> [arguments]")
  log.console("")
  log.console("Commands:")
  log.console("  init      Initialize a new Cell project")
  log.console("  get       Fetch and add a module dependency")
  log.console("  update    Update a dependency to a new version")
  log.console("  vendor    Copy all dependencies locally")
  log.console("  build     Compile all modules to bytecode")
  log.console("  patch     Create a patch for a module")
  log.console("  config    Manage system and actor configurations")
  log.console("  help      Show this help message")
  log.console("")
  log.console("Run 'cell help <command>' for more information on a command.")
}

$_.stop()