Skip to content

Commit

Permalink
Merge pull request #14 from dj8yfo/preselect_note_in_explore
Browse files Browse the repository at this point in the history
feat: added `select` flag to `explore` command as in `mds explore --s…
  • Loading branch information
dj8yfo authored Jun 17, 2023
2 parents 34a6ee7 + 87544a2 commit dd65aea
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 8 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@

All notable changes to this project will be documented in this file.

## [0.18.4] - 2023-06-14
## [0.18.5] - 2023-06-17

### Documentation

- Add note about env-substitute crate usage

### Features

- Added `select` flag to `explore` command as in `mds explore --select 'snippet | rust' --select syntaxes --select lib`

## [0.18.4] - 2023-06-15

### Documentation

Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mds"
version = "0.18.4"
version = "0.18.5"
author = ["dj8yf0μl"]
description = "A skim-based `*.md` explore and surf note-taking tool"
repository = "https://github.com/dj8yfo/meudeus"
Expand Down
2 changes: 1 addition & 1 deletion USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
```

```
meudeus v0.18.4
meudeus v0.18.5
a skim shredder for plain-text papers
Usage: mds [OPTIONS] <COMMAND>
Expand Down
13 changes: 12 additions & 1 deletion src/commands/explore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub static GLOBAL_STACK: &str = "GLOBAL";
#[allow(clippy::too_many_arguments)]
pub(crate) async fn exec(
db: SqliteAsyncHandle,
selected_note: Option<Vec<String>>,
external_commands: ExternalCommands,
surf_parsing: SurfParsing,
md_static: MarkdownStatic,
Expand All @@ -33,7 +34,17 @@ pub(crate) async fn exec(
stack_bindings_map: keymap::stack::Bindings,
explore_bindings_map: keymap::explore::Bindings,
) -> Result<String, anyhow::Error> {
let mut list = db.lock().await.list(md_static, color_scheme).await?;
let mut list = match selected_note {
Some(notes) => {
let mut result = vec![];
for note in notes {
let note = db.lock().await.get(&note, md_static, color_scheme).await?;
result.push(note);
}
result
}
None => db.lock().await.list(md_static, color_scheme).await?,
};
let mut straight = true;

let mut preview_type = PreviewType::default();
Expand Down
21 changes: 18 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[macro_use]
extern crate sql_builder;

use clap::ArgMatches;
use clap::{Arg, ArgAction, ArgMatches};

use colored::Colorize;
use config::{color::Color, Open as OpenCfg};
Expand Down Expand Up @@ -57,8 +57,8 @@ fn load_theme(color: Color) -> Option<&'static Theme> {
async fn main() {
env_logger::init();
let cmd = clap::Command::new("mds")
.version("v0.18.4")
.about("meudeus v0.18.4\na skim shredder for plain-text papers")
.version("v0.18.5")
.about("meudeus v0.18.5\na skim shredder for plain-text papers")
.bin_name("mds")
.arg(clap::arg!(-c --color "whether color output should be forced"))
.subcommand_required(true)
Expand Down Expand Up @@ -120,6 +120,16 @@ async fn main() {
)
.subcommand(
clap::command!("explore")
.arg(
Arg::new("select")
.short('s')
.long("select")
.action(ArgAction::Append)
.value_name("NOTE_NAME_FULL")
.help(
"full name of note to start explore with (may be used multiple times)",
),
)
.visible_alias("ex")
.about("explore notes by <c-h> (backlinks) , <c-l> (links forward)"),
)
Expand Down Expand Up @@ -196,8 +206,13 @@ async fn body(matches: &ArgMatches) -> anyhow::Result<String> {
.await
}
"explore" => {
let mut matches = matches.clone();
let selected_note = matches
.remove_many::<String>("select")
.map(|elems| elems.collect::<Vec<_>>());
commands::explore::exec(
db,
selected_note,
config.external_commands,
config.surf_parsing,
md_static,
Expand Down

0 comments on commit dd65aea

Please sign in to comment.