Make the index non-zero number

This commit is contained in:
TheAwiteb 2023-12-24 13:27:01 +03:00
parent 22a6ba3e48
commit fae55817bd
No known key found for this signature in database
GPG key ID: ABF818BD15DC2D34

View file

@ -14,6 +14,8 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/gpl-3.0.html>. // along with this program. If not, see <https://www.gnu.org/licenses/gpl-3.0.html>.
use std::num::NonZeroU64;
use clap::Args; use clap::Args;
use comfy_table::Table; use comfy_table::Table;
use regex::Regex; use regex::Regex;
@ -35,7 +37,7 @@ pub struct List {
/// Return the password with spesifc index /// Return the password with spesifc index
#[arg(short, long, value_name = "INDEX")] #[arg(short, long, value_name = "INDEX")]
get: Option<usize>, get: Option<NonZeroU64>,
/// Search and display only matching passwords. /// Search and display only matching passwords.
/// ///
/// The name and username will be searched. And service and note if included /// The name and username will be searched. And service and note if included
@ -79,7 +81,7 @@ impl RunCommand for List {
.enumerate() .enumerate()
.filter(|(idx, pass)| { .filter(|(idx, pass)| {
if let Some(index) = self.get { if let Some(index) = self.get {
return (idx + 1) == index; return (idx + 1) == index.get() as usize;
} }
if let Some(ref pattern) = self.search { if let Some(ref pattern) = self.search {
if self.regex { if self.regex {