/ src / cli / cerro_main.adb
cerro_main.adb
  1  --  Cerro Torre - Ship containers safely
  2  --  SPDX-License-Identifier: MIT OR AGPL-3.0-or-later
  3  --  Palimpsest-Covenant: 1.0
  4  --
  5  --  "Ship containers safely" - the distribution complement to
  6  --  Svalinn's "run containers nicely".
  7  
  8  with Ada.Text_IO;
  9  with Ada.Command_Line;
 10  with Cerro_CLI;
 11  
 12  procedure Cerro_Main is
 13     use Ada.Text_IO;
 14     use Ada.Command_Line;
 15  
 16     Version : constant String := "0.1.0-dev";
 17  begin
 18     if Argument_Count = 0 then
 19        Put_Line ("ct - Ship containers safely");
 20        Put_Line ("");
 21        Put_Line ("Usage: ct <command> [options]");
 22        Put_Line ("");
 23        Put_Line ("Core commands:");
 24        Put_Line ("  pack <image> -o <file>    Pack OCI image into .ctp bundle");
 25        Put_Line ("  verify <bundle>           Verify a .ctp bundle");
 26        Put_Line ("  explain <bundle>          Show verification chain");
 27        Put_Line ("");
 28        Put_Line ("Key management:");
 29        Put_Line ("  keygen                    Generate signing keypair");
 30        Put_Line ("  key <subcommand>          Key management (list, import, export)");
 31        Put_Line ("");
 32        Put_Line ("Distribution:");
 33        Put_Line ("  fetch <ref> -o <file>     Fetch bundle from registry");
 34        Put_Line ("  push <bundle> <dest>      Push bundle to registry");
 35        Put_Line ("  export <bundles> -o <ar>  Export for offline transfer");
 36        Put_Line ("  import <archive>          Import from offline archive");
 37        Put_Line ("");
 38        Put_Line ("Runtime:");
 39        Put_Line ("  run <bundle>              Run via Svalinn/podman/docker");
 40        Put_Line ("  unpack <bundle> -o <dir>  Extract to OCI layout");
 41        Put_Line ("");
 42        Put_Line ("Diagnostics:");
 43        Put_Line ("  doctor                    Check pipeline health");
 44        Put_Line ("  diff <old> <new>          Compare bundles");
 45        Put_Line ("");
 46        Put_Line ("Maintenance:");
 47        Put_Line ("  re-sign <bundle> -k <key> Re-sign with new key");
 48        Put_Line ("  policy <subcommand>       Policy management");
 49        Put_Line ("  index <dir>               Build searchable index");
 50        Put_Line ("  search <query>            Search bundles");
 51        Put_Line ("");
 52        Put_Line ("Options:");
 53        Put_Line ("  --help, -h                Show this help");
 54        Put_Line ("  --version, -v             Show version");
 55        Put_Line ("");
 56        Put_Line ("Examples:");
 57        Put_Line ("  ct pack docker.io/library/nginx:1.26 -o nginx.ctp");
 58        Put_Line ("  ct verify nginx.ctp --policy strict.json");
 59        Put_Line ("  ct run nginx.ctp --runtime=svalinn");
 60        Put_Line ("  ct diff old.ctp new.ctp");
 61        Put_Line ("");
 62        Set_Exit_Status (Failure);
 63        return;
 64     end if;
 65  
 66     declare
 67        Command : constant String := Argument (1);
 68     begin
 69        if Command = "--help" or Command = "-h" then
 70           Put_Line ("ct " & Version);
 71           Put_Line ("Ship containers safely - supply-chain verified distribution");
 72           Put_Line ("");
 73           Put_Line ("Run 'ct' without arguments for usage.");
 74           Put_Line ("See: https://cerro-torre.org");
 75  
 76        elsif Command = "--version" or Command = "-v" then
 77           Put_Line ("ct " & Version);
 78  
 79        --  Core commands (MVP v0.1)
 80        elsif Command = "pack" then
 81           Cerro_CLI.Run_Pack;
 82  
 83        elsif Command = "verify" then
 84           Cerro_CLI.Run_Verify;
 85  
 86        elsif Command = "explain" then
 87           Cerro_CLI.Run_Explain;
 88  
 89        elsif Command = "keygen" then
 90           Cerro_CLI.Run_Keygen;
 91  
 92        elsif Command = "key" then
 93           Cerro_CLI.Run_Key;
 94  
 95        --  Distribution commands
 96        elsif Command = "fetch" then
 97           Cerro_CLI.Run_Fetch;
 98  
 99        elsif Command = "push" then
100           Cerro_CLI.Run_Push;
101  
102        elsif Command = "export" then
103           Cerro_CLI.Run_Export;
104  
105        elsif Command = "import" then
106           Cerro_CLI.Run_Import;
107  
108        --  Runtime integration
109        elsif Command = "run" then
110           Cerro_CLI.Run_Run;
111  
112        elsif Command = "unpack" then
113           Cerro_CLI.Run_Unpack;
114  
115        --  Diagnostics
116        elsif Command = "doctor" then
117           Cerro_CLI.Run_Doctor;
118  
119        elsif Command = "diff" then
120           Cerro_CLI.Run_Diff;
121  
122        --  Maintenance
123        elsif Command = "re-sign" then
124           Cerro_CLI.Run_Resign;
125  
126        elsif Command = "policy" then
127           Cerro_CLI.Run_Policy;
128  
129        elsif Command = "index" then
130           Cerro_CLI.Run_Index;
131  
132        elsif Command = "search" then
133           Cerro_CLI.Run_Search;
134  
135        else
136           Put_Line ("Unknown command: " & Command);
137           Put_Line ("");
138           Put_Line ("Run 'ct --help' for usage.");
139           Set_Exit_Status (Failure);
140        end if;
141     end;
142  end Cerro_Main;