Skip to content

Commit ce35a36

Browse files
committed
template: add instructions to the template command
1 parent 632c9ba commit ce35a36

File tree

2 files changed

+31
-15
lines changed

2 files changed

+31
-15
lines changed

src/Command.zig

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,16 @@ fn printFullHelp(command: Command, io: IO, exe_path: []const u8) error{AlreadyHa
8383
if (result.output_name) try io.stdoutWriteAll(exe_path);
8484
}
8585

86-
if (command.extended_help) |extended_help| {
87-
std.debug.assert(extended_help.len != 0); // non-null extended help should not be empty
88-
std.debug.assert(extended_help[extended_help.len - 1] == '\n'); // extended help should end with a newline
86+
if (!std.mem.eql(u8, command.name, "template")) {
87+
if (command.extended_help) |extended_help| {
88+
std.debug.assert(extended_help.len != 0); // non-null extended help should not be empty
89+
std.debug.assert(extended_help[extended_help.len - 1] == '\n'); // extended help should end with a newline
8990

90-
try io.stdoutWriteByte('\n');
91-
try io.stdoutWriteAll(extended_help);
91+
try io.stdoutWriteByte('\n');
92+
try io.stdoutWriteAll(extended_help);
93+
}
94+
} else {
95+
std.debug.assert(command.extended_help.?.len == 0); // template has an extended help but it is empty
9296
}
9397
}
9498

@@ -287,9 +291,11 @@ pub fn testHelp(command: Command, comptime include_shorthand: bool) !void {
287291
}
288292
}
289293

290-
if (command.extended_help) |extended_help| {
291-
try sb.append(std.testing.allocator, '\n');
292-
try sb.appendSlice(std.testing.allocator, extended_help);
294+
if (!std.mem.eql(u8, command.name, "template")) { // template has an extended help but it is empty
295+
if (command.extended_help) |extended_help| {
296+
try sb.append(std.testing.allocator, '\n');
297+
try sb.appendSlice(std.testing.allocator, extended_help);
298+
}
293299
}
294300

295301
break :blk try sb.toOwnedSlice(std.testing.allocator);

src/commands/template.zig

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
// SPDX-License-Identifier: MIT
22
// SPDX-FileCopyrightText: 2025 Lee Cannon <[email protected]>
33

4+
// STEPS TO CREATE A NEW COMMAND:
5+
// - Copy this file and rename it to the name of the command
6+
// - Search the new file for "CHANGE THIS" and update the code
7+
// - Add the new command to `src/subcommands/listing.zig`
8+
// - Implement the functionality
9+
// - Add tests
10+
// - PROFIT
11+
412
/// Is this command enabled for the current target?
5-
pub const enabled: bool = true; // USE `shared.target_os` TO DETERMINE IF THE COMMAND IS ENABLED FOR THE CURRENT TARGET
13+
pub const enabled: bool = true; // CHANGE THIS - USE `shared.target_os` TO DETERMINE IF THE COMMAND IS ENABLED FOR THE CURRENT TARGET
614

715
pub const command: Command = .{
816
.name = "template", // CHANGE THIS
@@ -19,7 +27,9 @@ pub const command: Command = .{
1927
\\
2028
,
2129

22-
// ADD `.extended_help` IF EXAMPLES SHOULD BE DISPLAYED
30+
.extended_help = // CHANGE THIS - ADD EXAMPLES OR DELETE THIS IF NO EXAMPLES ARE NEEDED
31+
\\
32+
,
2333

2434
.execute = impl.execute,
2535
};
@@ -42,7 +52,7 @@ const impl = struct {
4252
log.debug("options={}", .{options});
4353
}
4454

45-
const TemplateOptions = struct {
55+
const TemplateOptions = struct { // CHANGE THIS - IF NO OPTIONS ARE NEEDED DELETE THIS
4656
pub fn format(
4757
options: TemplateOptions,
4858
comptime _: []const u8,
@@ -129,19 +139,19 @@ const impl = struct {
129139
};
130140
}
131141

132-
test "template no args" {
142+
test "template no args" { // CHANGE THIS
133143
try command.testExecute(&.{}, .{});
134144
}
135145

136-
test "template help" {
146+
test "template help" { // CHANGE THIS
137147
try command.testHelp(true);
138148
}
139149

140-
test "template version" {
150+
test "template version" { // CHANGE THIS
141151
try command.testVersion();
142152
}
143153

144-
test "template fuzz" { // DELETE THIS IF THE COMMAND INTERACTS WITH THE SYSTEM
154+
test "template fuzz" { // CHANGE THIS - DELETE THIS IF THE COMMAND INTERACTS WITH THE SYSTEM
145155
try command.testFuzz(.{});
146156
}
147157
};

0 commit comments

Comments
 (0)