llm
Download
24 lines 1 KiBCModified 2026-09-28 raw
123456789101112131415161718192021222324
// This file defines how to compile CLI argument parsing

#pragma once

#include "../ast.h"
#include "../environment.h"
#include "../stdlib/datatypes.h"
#include "../types.h"

// A roff comment prepended to every Tomo-generated man page. `tomo uninstall`
// scans for it so it only ever removes man pages Tomo itself produced (see
// is_tomo_manpage()), never a hand-written page that happens to share a name.
#define TOMO_MANPAGE_MARKER ".\\\" Generated by Tomo"

// One node in a program's subcommand tree (`func main.submodule.init(...)`):
typedef struct cli_command_def_s {
    const char *word; // the CLI word ("init"), with underscores converted to dashes
    binding_t *binding; // the subcommand function, or NULL for a pure namespace node
    struct cli_command_def_s *children, *next;
} cli_command_def_t;

cli_command_def_t *get_cli_subcommands(env_t *env);
Text_t compile_cli_dispatch(env_t *env, ast_t *file_ast, cli_command_def_t *commands, Text_t entry);
Text_t compile_manpage(Text_t program, ast_t *ast, arg_t *args, cli_command_def_t *commands);