Skip to content

Commit a7fee2d

Browse files
committed
Make the root command an instance of Command
fixes #70
1 parent 49c5f7f commit a7fee2d

4 files changed

Lines changed: 161 additions & 217 deletions

File tree

draft.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ This document is licensed under the MIT license
1313

1414
| Date | Author | Description |
1515
|------|--------|-------------|
16+
| 2026-04-19 | Bob Lail | Made the root command an instance of [Command Object](#command-object) |
1617
| 2026-03-24 | Bob Lail | Add default value for `arity` to [Argument Object](#argument-object) |
1718
| 2025-07-15 | Patrik Svensson | Added `interactive` to root command and commands |
1819
| 2025-07-16 | Patrik Svensson | Added [Metadata Object](#metadata-object) |
@@ -102,15 +103,9 @@ This is the root object of the OpenCLI Description.
102103
| Field Name | Type | Default Value | Description |
103104
|------------|:----:|---------------|-------------|
104105
| opencli | `string` | - | **REQUIRED** The OpenCLI version number |
106+
| command | [Command Object](#command-object) | - | **REQUIRED** The root command |
105107
| info | [CliInfo Object](#cliinfo-object) | - | **REQUIRED** Information about the CLI |
106108
| conventions | [Conventions Object](#conventions-object) | - | The conventions used by the CLI |
107-
| arguments | [[Argument Object](#argument-object)] | - | Root command arguments |
108-
| options | [[Option Object](#option-object)] | - | Root command options |
109-
| commands | [[Command Object](#command-object)] | - | Root command sub commands |
110-
| exitCodes | [[ExitCode Object](#exitcode-object)] | - | Root command exit codes |
111-
| examples | [`string`] | - | Examples of how to use the CLI |
112-
| interactive | `bool` | `false` | Indicates whether or not the command requires interactive input |
113-
| metadata | [[Metadata Object](#metadata-object)] | - | Custom metadata |
114109

115110
#### CliInfo Object
116111

examples/dotnet.json

Lines changed: 51 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,56 @@
11
{
22
"$schema": "../schema.json",
33
"opencli": "0.1",
4+
"command": {
5+
"name": "dotnet",
6+
"options": [
7+
{
8+
"name": "--help",
9+
"aliases": [ "-h" ],
10+
"description": "Display help."
11+
},
12+
{
13+
"name": "--info",
14+
"description": "Display .NET information."
15+
},
16+
{
17+
"name": "--list-sdks",
18+
"description": "Display the installed SDKs."
19+
},
20+
{
21+
"name": "--list-runtimes",
22+
"description": "Display the installed runtimes."
23+
}
24+
],
25+
"commands": [
26+
{
27+
"name": "build",
28+
"arguments": [
29+
{
30+
"name": "PROJECT | SOLUTION",
31+
"description": "The project or solution file to operate on. If a file is not specified, the command will search the current directory for one.",
32+
}
33+
],
34+
"options": [
35+
{
36+
"name": "--configuration",
37+
"aliases": [ "-c" ],
38+
"description": "The configuration to use for building the project. The default for most projects is 'Debug'.",
39+
"arguments": [
40+
{
41+
"name": "CONFIGURATION",
42+
"required": true,
43+
"arity": {
44+
"minimum": 1,
45+
"maximum": 1
46+
}
47+
}
48+
]
49+
}
50+
]
51+
}
52+
]
53+
},
454
"info": {
555
"title": "dotnet",
656
"version": "9.0.1",
@@ -10,52 +60,5 @@
1060
"identifier": "MIT",
1161
"url": "https://opensource.org/license/mit"
1262
}
13-
},
14-
"options": [
15-
{
16-
"name": "--help",
17-
"aliases": [ "-h" ],
18-
"description": "Display help."
19-
},
20-
{
21-
"name": "--info",
22-
"description": "Display .NET information."
23-
},
24-
{
25-
"name": "--list-sdks",
26-
"description": "Display the installed SDKs."
27-
},
28-
{
29-
"name": "--list-runtimes",
30-
"description": "Display the installed runtimes."
31-
}
32-
],
33-
"commands": [
34-
{
35-
"name": "build",
36-
"arguments": [
37-
{
38-
"name": "PROJECT | SOLUTION",
39-
"description": "The project or solution file to operate on. If a file is not specified, the command will search the current directory for one.",
40-
}
41-
],
42-
"options": [
43-
{
44-
"name": "--configuration",
45-
"aliases": [ "-c" ],
46-
"description": "The configuration to use for building the project. The default for most projects is 'Debug'.",
47-
"arguments": [
48-
{
49-
"name": "CONFIGURATION",
50-
"required": true,
51-
"arity": {
52-
"minimum": 1,
53-
"maximum": 1
54-
}
55-
}
56-
]
57-
}
58-
]
59-
}
60-
]
63+
}
6164
}

0 commit comments

Comments
 (0)