aboutsummaryrefslogtreecommitdiff
path: root/src/commands.rs
Commit message (Collapse)AuthorAge
* Merge ExecCtx and RunCtx into ContextRobin Krahl2020-09-05
| | | | | | | Since we moved the model, no_cache and verbosity fields from ExecCtx into Config and added a Config field to both ExecCtx and RunCtx, RunCtx and ExecCtx are identical. Therefore this patch merges the ExecCtx and RunCtx structs into the new Context struct.
* Implement configuration handlingRobin Krahl2020-09-05
| | | | | | | | | This patch implements basic configuration handling that reads a configuration file and stores the parsed data in the ExecCtx and RunCtx structs. It supports three configuration items: - model (previously only --model) - no_cache (previously only NITROCLI_NO_CACHE) - verbosity (previously only --verbose)
* Remove no longer necessary msg parameter from try_with_* functionsDaniel Mueller2020-08-29
| | | | | | | | | With the move to using anyhow's Error type and adding contextual information at the point where we bubble up errors, we no longer require the 'msg' argument that is passed to the try_with_pin_* and authenticate functions. To that end, this change removes this parameter, concluding the switch to using anyhow.
* Use anyhow for error handlingDaniel Mueller2020-08-28
| | | | | | | | | | | This patch changes our error handling approach from the ground up: instead of having a globally used Error enum that contains variants for all possible errors, we now use anyhow's Error type. This approach is more dynamic (and not statically typed), but it allows for more fine grained error messages and overall more user-friendly error reporting. Overall it also is a net simplification. While we have one dynamic cast now, in order to be able to handle erroneous password/PIN entries correctly, that is considered a reasonable compromise.
* Rename arg_defs.rs to args.rsDaniel Mueller2020-04-11
| | | | | | We have never been fully satisfied with the name arg_defs. Now that we have gotten rid of the formerly used args module, this change renames arg_defs to args.
* Merge remaining bits of args.rs into main.rsDaniel Mueller2020-04-11
| | | | | | This change removes the args module by moving all remaining functionality in it into main.rs. The result is arguably a nice consolidation of all context related definitions in a single module.
* Merge config_set function into commands.rsDaniel Mueller2020-04-11
| | | | | | As a next step moving us closer towards removing the args module, this change merges the config_set function into the existing function of the same name in the commands module.
* Merge otp_set function into commands.rsDaniel Mueller2020-04-10
| | | | | | | | | Now that we have isolated and separated out structopt specific definitions into a new module, arg_defs, args.rs is actually so small that we do not want to keep it around any longer. This change marks a first step moving us closer towards removing it. Specifically, it merges the otp_set function from args.rs into the function of the same name in commands.rs.
* Move PinType type into arg_defs moduleDaniel Mueller2020-04-02
| | | | | | | | The PinType struct, despite being intended for the pinentry module, is ultimately part of the argument handling definitions. Because our goal is to consolidate all of those in a single file, this change moves the definition of this type from the pinentry module into the newly introduced arg_defs.
* Factor out arg_defs.rs for argument parsing related typesDaniel Mueller2020-04-01
| | | | | | | | This change marks the first step in a restructuring of the argument handling code, the ultimate goal of which is a separation of the type definitions as used by structopt from the logic associated with it. This change in particular introduces a new module, arg_defs, that contains all those type definitions that previously resided in the args module.
* Update nitrokey dependency to 0.6.0Robin Krahl2020-01-29
| | | | | | nitrokey 0.6.0 introduced the SerialNumber struct (instead of representing serial numbers as strings). We no longer have to manually format the serial number as SerialNumber implements Display.
* Implement list commandRobin Krahl2020-01-14
| | | | | | | | | | | | | | | This patch implements the list command that lists all attached Nitrokey devices. Currently the Nitrokey Storage does not report its serial number during HID enumeration, see [0]. So if we detect a Nitrokey Storage device, we connect to it and use the get_serial_number function to query its serial number. This can be disabled using the --no-connect option. Note that even the get_serial_number function reports a wrong serial number for the Nitrokey Storage, see [1]. [0] https://github.com/Nitrokey/nitrokey-storage-firmware/issues/88 [1] https://github.com/Nitrokey/nitrokey-storage-firmware/issues/76
* Add scaffolding for the list commandRobin Krahl2020-01-14
| | | | | This patch adds the basic scaffolding for the list command which will list all attached Nitrokey devices.
* Bump nitrokey dependency to version 0.5.1Robin Krahl2020-01-14
| | | | | | This change updates the version of the nitrokey crate that we use to 0.5.1. As part of that, it replaces occurrences of Storage::get_status with Storage::get_storage_status as the method has been renamed.
* Move nitrocli source code into repository rootDaniel Mueller2020-04-04
Now that all vendored dependencies have been removed, this change moves the program's source code from the nitrocli/ directory into the root of the repository.