#!/usr/bin/env nu
# Get help category for a command (if it requires arguments)
# Usage: nu get-help-category.nu <schema_file> <command>

use ../lib_provisioning/utils/nickel_processor.nu [ncl-eval]

def main [schema_file: string, cmd: string] {
    let json = (ncl-eval $schema_file [])
    let commands = $json.commands
    let result = ($commands | where { |c|
        (($c.command == $cmd) or ($c.aliases | any { |a| $a == $cmd })) and $c.requires_args
    } | first)

    if ($result | is-not-empty) {
        $result.help_category
    } else {
        ""
    }
}
