Skip to content

Commit a659c2c

Browse files
committed
[sweep] add --prompt-icon option
1 parent a0c179d commit a659c2c

File tree

5 files changed

+42
-26
lines changed

5 files changed

+42
-26
lines changed

Cargo.lock

+33-22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sweep/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ authors = ["Pavel Aslanov <[email protected]>"]
33
build = "build.rs"
44
edition = "2021"
55
name = "sweep"
6-
version = "0.16.5"
6+
version = "0.16.6"
77
include = ["**/*.rs", "src/icons.json", "Cargo.toml", "Cargo.lock", "README.md"]
88

99
[lib]

sweep/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ mod candidate;
1414
pub use candidate::{fields_view, Candidate, CandidateContext, Field, FieldRef, FieldSelector};
1515

1616
mod sweep;
17-
pub use crate::sweep::{sweep, Sweep, SweepEvent, SweepOptions};
17+
pub use crate::sweep::{sweep, Sweep, SweepEvent, SweepOptions, PROMPT_DEFAULT_ICON};
1818

1919
pub mod rpc;
2020

sweep/src/main.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use std::{
1212
pin::Pin,
1313
sync::{Arc, Mutex},
1414
};
15+
use surf_n_term::Glyph;
1516
use sweep::{
1617
common::{json_from_slice_seed, VecDeserializeSeed},
1718
Candidate, CandidateContext, FieldSelector, Sweep, SweepEvent, SweepOptions, Theme,
@@ -110,14 +111,14 @@ async fn main() -> Result<(), Error> {
110111
SweepOptions {
111112
height: args.height,
112113
prompt: args.prompt.clone(),
114+
prompt_icon: Some(args.prompt_icon),
113115
theme,
114116
keep_order: args.keep_order,
115117
tty_path: args.tty_path.clone(),
116118
title: args.title.clone(),
117119
scorers: VecDeque::new(),
118120
altscreen: args.altscreen,
119121
border: args.border,
120-
..SweepOptions::default()
121122
},
122123
)?;
123124
sweep.query_set(args.query.clone());
@@ -214,6 +215,10 @@ pub struct Args {
214215
#[argh(option, short = 'p', default = "\"INPUT\".to_string()")]
215216
pub prompt: String,
216217

218+
/// prompt icon `Glyph::form_str`
219+
#[argh(option, default = "sweep::PROMPT_DEFAULT_ICON.clone()")]
220+
pub prompt_icon: Glyph,
221+
217222
/// initial query string
218223
#[argh(option, default = "String::new()")]
219224
pub query: String,

sweep/src/sweep.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ lazy_static::lazy_static! {
4444
static ref ICONS: HashMap<String, Glyph> =
4545
serde_json::from_str(include_str!("./icons.json"))
4646
.expect("invalid icons.json file");
47-
static ref PROMPT_DEFAULT_ICON: &'static Glyph = ICONS.get("prompt")
47+
pub static ref PROMPT_DEFAULT_ICON: &'static Glyph = ICONS.get("prompt")
4848
.expect("failed to get prompt default icon");
4949
static ref KEYBOARD_ICON: &'static Glyph = ICONS.get("keyboard")
5050
.expect("failed to get keyboard icon");

0 commit comments

Comments
 (0)