Skip to content

Commit

Permalink
refactor(Command): Rename findArgBy* to find*Option
Browse files Browse the repository at this point in the history
  • Loading branch information
PrajwalCH committed Oct 8, 2022
1 parent ab4ee0b commit 10ad491
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Command.zig
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ pub fn countSubcommands(self: *const Command) usize {

/// Linearly searches for an argument with short name equals to given `short_name`.
/// Returns a const pointer of a found argument otherwise null.
pub fn findArgByShortName(self: *const Command, short_name: u8) ?*const Arg {
pub fn findShortOption(self: *const Command, short_name: u8) ?*const Arg {
for (self.options.items) |*arg| {
if (arg.short_name) |s| {
if (s == short_name) return arg;
Expand All @@ -124,7 +124,7 @@ pub fn findArgByShortName(self: *const Command, short_name: u8) ?*const Arg {

/// Linearly searches for an argument with long name equals to given `long_name`.
/// Returns a const pointer of a found argument otherwise null.
pub fn findArgByLongName(self: *const Command, long_name: []const u8) ?*const Arg {
pub fn findLongOption(self: *const Command, long_name: []const u8) ?*const Arg {
for (self.options.items) |*arg| {
if (arg.long_name) |l| {
if (mem.eql(u8, l, long_name)) return arg;
Expand Down
4 changes: 2 additions & 2 deletions src/parser/Parser.zig
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ fn parseShortOption(self: *Parser, token: *const Token) InternalError!void {
while (short_option.next()) |option| {
self.err_builder.setProvidedArg(@as(*const [1]u8, option));

const arg = self.cmd.findArgByShortName(option.*) orelse {
const arg = self.cmd.findShortOption(option.*) orelse {
return Error.UnknownFlag;
};
self.err_builder.setArg(arg);
Expand Down Expand Up @@ -251,7 +251,7 @@ fn parseLongOption(self: *Parser, token: *const Token) InternalError!void {
const option_tuple = optionTokenToOptionTuple(token);
self.err_builder.setProvidedArg(option_tuple[0]);

const arg = self.cmd.findArgByLongName(option_tuple[0]) orelse {
const arg = self.cmd.findLongOption(option_tuple[0]) orelse {
return Error.UnknownFlag;
};
self.err_builder.setArg(arg);
Expand Down

0 comments on commit 10ad491

Please sign in to comment.