Received: from mail.typed-hole.org (mail.typed-hole.org [199.247.9.36]) by mail-b.sr.ht (Postfix) with ESMTPS id 29E20FF183 for <~julienxx/asuka@lists.sr.ht>; Mon, 9 Nov 2020 11:39:34 +0000 (UTC) Authentication-Results: mail-b.sr.ht; dkim=pass (2048-bit key) header.d=typed-hole.org header.i=@typed-hole.org header.b=U1b8O+bw Received: from mail.typed-hole.org (localhost [127.0.0.1]) by mail.typed-hole.org (OpenSMTPD) with ESMTP id d254c454; Mon, 9 Nov 2020 11:39:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=typed-hole.org; h= mime-version:content-transfer-encoding:content-type:from:to :subject:date:message-id:in-reply-to; s=20190925; bh=e+XWRTEfyJI 2uWi7X70tePGdgX4=; b=U1b8O+bwlu5YsYaHW/3O3NSZTtlkt1KJ1eKH96gssl+ WdP1c/dDcBxI9+zR4cj63vUnzWFwR2eXAb6KAl/vWbik4jGAuaiIVinBSF8MoUM+ ZqbfYyLRvCidCgW12Hl+QXB6pN8oysXmjVDXvZ+XWXi9dm34DpIxfpiWF0IGyg5p zRdUZRoMrdaxvig+pU0FS/1vT+/V+YfK8iDqMt4jySbmPhlNRkF+rCyUPAqaEg0Z FfnVS3UuYubirsIgYJ8uy6afeZ6zuBU9ouYwsYGmIecEG2CBXSelZ7FJBc9v0Nnx ZaU87jkMyMuu1Bebbqvg0saORdDm1Cmls9dCwLyH7Ag== DomainKey-Signature: a=rsa-sha1; c=nofws; d=typed-hole.org; h= mime-version:content-transfer-encoding:content-type:from:to :subject:date:message-id:in-reply-to; q=dns; s=20190925; b=vYan4 FNZsVoCOingAlihnObw+AQMLmBCpfF+F0iNQZZyUWpimltxc0j7yps2bjiovYS/3 K7SF/pKlxILbOBTJpAQn0w0ZHjZZaYnNJ2cDlXkr87Dtu6H0soBRAT6+zHXSdcW2 8PmdJxOpFp7u0qAdmAjtLCnsTafh6OlMs/D4Ve+Y1v9BbNhibaUoLOqnQgHLsv0r TP1lhv9cn9q8+K1T0bkUd8y7i0D5vYvSq4gw86NDHbe1aMjwZL7iLpivM9NxH2LE /QP2DMEtqveipOa6ZT6mGX9sGwxfyegYZ5V3CZOuDqIa7fZpcGoIeGTU5xyTg4BY mLHLj+bxs3KHsI3yA== Received: from localhost (87-231-19-8.rev.numericable.fr [87.231.19.8]) by mail.typed-hole.org (OpenSMTPD) with ESMTPSA id 41e2eadd (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO); Mon, 9 Nov 2020 11:39:26 +0000 (UTC) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 From: "Julien Blanchard" To: , <~julienxx/asuka@lists.sr.ht> Subject: Re: [PATCH] add secret input capability Date: Mon, 09 Nov 2020 12:38:04 +0100 Message-Id: In-Reply-To: <20201108152659.4676-1-johann.galle@gmx.net> Thanks for the patch! How about creating a new Status::Secret that would be using a prompt_for_secret_answer method? On Sun Nov 8, 2020 at 4:27 PM CET, Johann150 wrote: > From: Johann150 > > This adds the secret input capability as specified for status code 11. > --- > Tested. > > src/main.rs | 24 ++++++++++++++---------- > src/status.rs | 5 +++-- > 2 files changed, 17 insertions(+), 12 deletions(-) > > diff --git a/src/main.rs b/src/main.rs > index a8c2087..2f67844 100644 > --- a/src/main.rs > +++ b/src/main.rs > @@ -98,20 +98,24 @@ fn prompt_for_url(s: &mut Cursive) { > ); > } > > -fn prompt_for_answer(s: &mut Cursive, url: Url, message: String) { > +fn prompt_for_answer(s: &mut Cursive, url: Url, message: String, > secret: bool) { > s.add_layer( > Dialog::new() > .title(message) > // Padding is (left, right, top, bottom) > .padding((1, 1, 1, 0)) > .content( > - EditView::new() > - .on_submit(move |s, response| { > - let link =3D format!("{}?{}", url.to_string(), response); > - s.pop_layer(); > - follow_link(s, &link); > - }) > - .fixed_width(60), > + if secret { > + EditView::new().secret() > + } else { > + EditView::new() > + } > + .on_submit(move |s, response| { > + let link =3D format!("{}?{}", url.to_string(), response); > + s.pop_layer(); > + follow_link(s, &link); > + }) > + .fixed_width(60), > ) > .with_id("url_query"), > ); > @@ -239,8 +243,8 @@ fn handle_response_status( > )); > None > } > - Status::Input(message) =3D> { > - prompt_for_answer(s, url_copy, message); > + Status::Input(message, secret) =3D> { > + prompt_for_answer(s, url_copy, message, secret); > None > } > other_status =3D> { > diff --git a/src/status.rs b/src/status.rs > index 2b70940..d6aad96 100644 > --- a/src/status.rs > +++ b/src/status.rs > @@ -5,7 +5,7 @@ use std::str::FromStr; > > #[derive(Debug)] > pub enum Status { > - Input(String), > + Input(String, bool), > Success(String), > SuccessEndOfClientCertificateSession(String), > RedirectTemporary(String), > @@ -58,7 +58,8 @@ impl FromStr for Status { > > fn make_status(code: i16, meta: String) -> Status { > match code { > - 10 =3D> Status::Input(meta), > + 10 =3D> Status::Input(meta, false), > + 11 =3D> Status::Input(meta, true), > 20 =3D> Status::Success(meta), > 21 =3D> Status::SuccessEndOfClientCertificateSession(meta), > 30 =3D> Status::RedirectTemporary(meta), > -- > 2.20.1