Skip to content

Commit

Permalink
Suggest elp shell when running eqwalize-all
Browse files Browse the repository at this point in the history
Summary:
Add a message during `elp eqwalize-all` to suggest the use of ELP shell.

Add an introductory help message to `elp shell`.

Reviewed By: ilya-klyuchnikov

Differential Revision: D58234882

fbshipit-source-id: 7d00422e73ff5e2b17665138dbcf3a4d418da531
  • Loading branch information
VLanvin authored and facebook-github-bot committed Jun 10, 2024
1 parent bab39dc commit 9326281
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
16 changes: 16 additions & 0 deletions crates/elp/src/bin/eqwalizer_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ use std::sync::Arc;
use anyhow::bail;
use anyhow::Context;
use anyhow::Result;
use codespan_reporting::term::termcolor::Color;
use codespan_reporting::term::termcolor::ColorSpec;
use elp::build;
use elp::build::load;
use elp::build::types::LoadResult;
Expand Down Expand Up @@ -42,6 +44,7 @@ use elp_project_model::ProjectBuildData;
use fxhash::FxHashMap;
use indicatif::ParallelProgressIterator;
use itertools::Itertools;
use lazy_static::lazy_static;
use rayon::prelude::*;

use crate::args::Eqwalize;
Expand Down Expand Up @@ -109,11 +112,16 @@ pub fn do_eqwalize_module(
})
}

pub const SHELL_HINT: &str = "\
eqWAlizing frequently? Consider using command \x1b[0;33melp shell\x1b[0m to cut down on processing time.";

pub fn eqwalize_all(
args: &EqwalizeAll,
cli: &mut dyn Cli,
query_config: &BuckQueryConfig,
) -> Result<()> {
// Hack to avoid hint appearing in tests
cli.spinner(SHELL_HINT).finish();
let config = DiscoverConfig::new(args.rebar, &args.profile);
let mut loaded = load::load_project_at(
cli,
Expand Down Expand Up @@ -523,3 +531,11 @@ fn set_eqwalizer_config(loaded: &mut LoadResult, clause_coverage: bool) -> () {
db.set_eqwalizer_config(Arc::new(config));
}
}

lazy_static! {
static ref YELLOW_COLOR_SPEC: ColorSpec = {
let mut spec = ColorSpec::default();
spec.set_fg(Some(Color::Yellow));
spec
};
}
7 changes: 7 additions & 0 deletions crates/elp/src/bin/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,12 @@ COMMANDS:
--clause-coverage Use experimental clause coverage checker
";

pub const WELCOME: &str = "\
\n
ELP shell automatically keeps state in between eqWAlizer commands to cut down on processing time.
Type \x1b[0;33mhelp\x1b[0m to see available commands (eqwalize, eqwalize-all, ...).\n
";

// Adapted from elp::server
fn process_changes_to_vfs_store(loaded: &mut LoadResult) -> bool {
let changed_files = loaded.vfs.take_changes();
Expand Down Expand Up @@ -337,6 +343,7 @@ pub fn run_shell(shell: &Shell, cli: &mut dyn Cli, query_config: &BuckQueryConfi
)?;
let mut rl = rustyline::DefaultEditor::new()?;
let mut last_read = watchman.get_clock()?;
write!(cli, "{}", WELCOME)?;
loop {
let readline = rl.readline("> ");
match readline {
Expand Down

0 comments on commit 9326281

Please sign in to comment.