better error message when there is no parameter after 'show'
This commit is contained in:
@@ -19,7 +19,9 @@ pub fn main() !void {
|
||||
Base32Error.InvalidCharacter, Base32Error.InvalidPadding => {
|
||||
try std.io.getStdErr().writer().print("The secret is invalid.\n", .{});
|
||||
},
|
||||
ArgumentError.UnknownParameter => {
|
||||
ArgumentError.UnknownParameter, //
|
||||
ArgumentError.MissingAuthenticatorParam,
|
||||
=> {
|
||||
// do nothing, error message is already written (because the message contains the name of the unknown parameter)
|
||||
},
|
||||
ArgumentError.InvalidOtpAuthUrl => {},
|
||||
@@ -164,7 +166,7 @@ fn zeroPad(allocator: Allocator, digits: u4, x: anytype) ![]u8 {
|
||||
return result;
|
||||
}
|
||||
|
||||
const ArgumentError = error{ InvalidOtpAuthUrl, UnknownParameter, MissingConfigLocation, AuthenticatorNotFound };
|
||||
const ArgumentError = error{ InvalidOtpAuthUrl, UnknownParameter, MissingConfigLocation, AuthenticatorNotFound, MissingAuthenticatorParam };
|
||||
|
||||
fn parseArgs(allocator: Allocator, args: []const []const u8) !Args {
|
||||
var result = Args{
|
||||
@@ -187,7 +189,8 @@ fn parseArgs(allocator: Allocator, args: []const []const u8) !Args {
|
||||
} else if (eql(u8, "show", arg)) {
|
||||
i += 1;
|
||||
if (i >= args.len) {
|
||||
return error.MissingConfigLocation;
|
||||
std.debug.print("expected authenticator name after command 'show'\n get a list of available authenticators with 'zig-totp list'\n", .{});
|
||||
return error.MissingAuthenticatorParam;
|
||||
}
|
||||
result.show = args[i];
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user