Skip to content

Commit ee7480e

Browse files
committed
Document sort
1 parent 51f74ba commit ee7480e

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/prompts/multi_select.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl<'a> MultiSelect<'a> {
122122
self.interact_on(&Term::stderr())
123123
}
124124

125-
/// Like `interact` but allows a specific terminal to be set.
125+
/// Like [interact](#method.interact) but allows a specific terminal to be set.
126126
pub fn interact_on(&self, term: &Term) -> io::Result<Vec<usize>> {
127127
let mut page = 0;
128128

src/prompts/sort.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ use crate::theme::{SimpleTheme, TermThemeRenderer, Theme};
55
use console::{Key, Term};
66

77
/// Renders a sort prompt.
8+
///
9+
/// Returns list of indices in original items list sorted according to user input.
10+
///
11+
/// ## Example usage
12+
/// ```rust,no_run
13+
/// let items_to_order = vec!["Item 1", "Item 2", "Item 3"];
14+
/// let ordered = Sort::new()
15+
/// .with_prompt("Order the items")
16+
/// .items(&items_to_order)
17+
/// .interact()?;
18+
/// ```
819
pub struct Sort<'a> {
920
items: Vec<String>,
1021
prompt: Option<String>,
@@ -44,7 +55,7 @@ impl<'a> Sort<'a> {
4455

4556
/// Sets the clear behavior of the menu.
4657
///
47-
/// The default is to clear the menu.
58+
/// The default is to clear the menu after user interaction.
4859
pub fn clear(&mut self, val: bool) -> &mut Sort<'a> {
4960
self.clear = val;
5061
self
@@ -81,7 +92,7 @@ impl<'a> Sort<'a> {
8192
self.interact_on(&Term::stderr())
8293
}
8394

84-
/// Like `interact` but allows a specific terminal to be set.
95+
/// Like [interact](#method.interact) but allows a specific terminal to be set.
8596
pub fn interact_on(&self, term: &Term) -> io::Result<Vec<usize>> {
8697
let mut page = 0;
8798

0 commit comments

Comments
 (0)