~necaris/totp-fun

dd0fd78a6473e07a1c7fb2fef20ece6c1592423f — Rami Chowdhury 2 years ago 0e8c695
Improve help messages
4 files changed, 8 insertions(+), 5 deletions(-)

M rust/src/main.rs
M totp.lisp
M totp.pl
M totp.py
M rust/src/main.rs => rust/src/main.rs +1 -1
@@ 71,7 71,7 @@ fn calc_totp(secret: &[u8], timestamp: u64) -> (u32, u8) {
}

fn usage(program: &str, opts: Options) -> String {
    let brief = format!("Usage: {} FILE [options]", program);
    let brief = format!("Compute TOTP codes given base32-encoded secret\nUsage: {} SECRET [options]", program);
    opts.usage(&brief)
}


M totp.lisp => totp.lisp +4 -2
@@ 14,7 14,7 @@
(opts:define-opts
    (:name :help
     :short #\h
     :description "Compute the TOTP digits given a SECRET")
     :description "Compute the TOTP digits given a base32-encoded secret")
    (:name :verbose
     :long "verbose"
     :description "Whether to print out more helpful information. What that may be is TBD"))


@@ 42,7 42,9 @@ convenience, also return the remaining time."
  (multiple-value-bind (options free-args)
      (opts:get-opts args)
    (when (getf options :help)
      (opts:describe)
      (opts:describe
       :prefix "Compute TOTP code, given a secret value."
       :args "SECRET")
      (opts:exit))
    (when (< (length free-args) 1)
      (write-line "SECRET is required!")

M totp.pl => totp.pl +2 -1
@@ 30,7 30,8 @@ sub main {
    }
    # (1) quit unless we have the correct number of command-line args
    my $num_args = $#ARGV + 1;
    if ($num_args < 1) {
    if (($num_args < 1) or (grep(/-h/, @ARGV))) {
        print "Compute TOTP codes given a base32-encoded secret";
        print "\nUsage: totp.pl [-v | --verbose] SECRET\n";
        exit 1;
    }

M totp.py => totp.py +1 -1
@@ 25,7 25,7 @@ def calc_otp(secret: bytes, timestamp: float) -> T.Tuple[int, int]:


def main():
    p = argparse.ArgumentParser()
    p = argparse.ArgumentParser(description="Compute TOTP code given secret")
    p.add_argument("secret", metavar="SECRET", help="base32-encoded secret value")
    p.add_argument("--verbose", type=bool, help="whether to print more info")