Skip to content

Pick daily leetcode problem #66

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 17, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
add --daily cli option for pick subcommand
  • Loading branch information
152334H committed May 16, 2022
commit 6e067ce42c5bac298a9d85c3d52b56e2ce692df1
12 changes: 12 additions & 0 deletions src/cmds/pick.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ impl Command for PickCommand {
.takes_value(true)
.help("Filter questions by tag"),
)
.arg(
Arg::with_name("daily")
.short("d")
.long("daily")
.takes_value(false)
.help("Pick today's daily challenge"),
)
}

/// `pick` handler
Expand Down Expand Up @@ -109,9 +116,14 @@ impl Command for PickCommand {
crate::helper::filter(&mut problems, query.to_string());
}

let daily_id = if m.is_present("daily") {
Some(cache.get_daily_problem_id().await?)
} else { None };

let fid = m
.value_of("id")
.and_then(|id| id.parse::<i32>().ok())
.or(daily_id)
.unwrap_or_else(|| {
// Pick random without specify id
let problem = &problems[rand::thread_rng().gen_range(0, problems.len())];
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy