Implemented do ra_check command for enabling/disabling rust-analyzer check.
This commit is contained in:
parent
a7cfd2b827
commit
20debfd7d9
|
@ -62,6 +62,16 @@
|
|||
"problemMatcher": [
|
||||
"$rustc"
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "do ra_check",
|
||||
"type": "shell",
|
||||
"command": "cargo do ra_check",
|
||||
"presentation": {
|
||||
"reveal": "never",
|
||||
"clear": true
|
||||
},
|
||||
"problemMatcher": []
|
||||
}
|
||||
],
|
||||
"inputs": [
|
||||
|
|
|
@ -8,8 +8,4 @@
|
|||
the event can be coalesced?
|
||||
* Timer and resize updates are causing problems.
|
||||
* Slow frame upload (2ms for 2mb)?
|
||||
* Crash respawn deadlocking.
|
||||
|
||||
# DO
|
||||
|
||||
* Implement `rust_analyzer_check` cancellation.
|
||||
* Crash respawn deadlocking.
|
|
@ -18,9 +18,8 @@ fn main() {
|
|||
// the offset of the first '[' character in the comment block.
|
||||
let mut details_arg_offset = 0;
|
||||
for line in rs.lines() {
|
||||
if line.starts_with("// do ") {
|
||||
if let Some(task_line) = line.strip_prefix("// do ") {
|
||||
expect_details = true;
|
||||
let task_line = &line["// do ".len()..];
|
||||
let (names, options) = parse_task_line(task_line);
|
||||
let mut names = names.into_iter();
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ fn main() {
|
|||
let (task, args) = args();
|
||||
|
||||
match task {
|
||||
"ra_check" => ra_check(args),
|
||||
"rust_analyzer_check" => rust_analyzer_check(args),
|
||||
"fmt" | "f" => fmt(args),
|
||||
"test" | "t" => test(args),
|
||||
|
@ -181,7 +182,6 @@ fn test(mut args: Vec<&str>) {
|
|||
if all_patterns.iter().any(|a| build_tests.contains(a)) {
|
||||
// all build tests.
|
||||
cmd_env("cargo", &build_tests_args, &args, &[("TRYBUILD", overwrite)]);
|
||||
return;
|
||||
} else {
|
||||
// specific test files.
|
||||
let mut args = build_tests_args;
|
||||
|
@ -546,8 +546,43 @@ fn rust_analyzer_run(args: Vec<&str>) {
|
|||
}
|
||||
|
||||
fn rust_analyzer_check(mut args: Vec<&str>) {
|
||||
args.push("--message-format=json");
|
||||
check(args);
|
||||
if !settings_path().join(".rust_analyzer_disabled").exists() {
|
||||
args.push("--message-format=json");
|
||||
check(args);
|
||||
}
|
||||
}
|
||||
|
||||
// do ra_check [--on,--off]
|
||||
// Enables or disables rust-analyzer check.
|
||||
// USAGE:
|
||||
// ra_check --on
|
||||
// Enables rust-analyzer check.
|
||||
// ra_check --off
|
||||
// Disables rust-analyzer check.
|
||||
// ra_check
|
||||
// Toggles rust-analyzer check.
|
||||
fn ra_check(mut args: Vec<&str>) {
|
||||
let path = settings_path().join(".rust_analyzer_disabled");
|
||||
|
||||
let enable = if take_flag(&mut args, &["--on"]) {
|
||||
true
|
||||
} else if take_flag(&mut args, &["--off"]) {
|
||||
false
|
||||
} else {
|
||||
path.exists()
|
||||
};
|
||||
|
||||
if enable {
|
||||
if let Err(e) = std::fs::remove_file(path) {
|
||||
if e.kind() != std::io::ErrorKind::NotFound {
|
||||
panic!("{:?}", e)
|
||||
}
|
||||
}
|
||||
println("rust-analyzer check is enabled");
|
||||
} else {
|
||||
let _ = std::fs::File::create(path).unwrap();
|
||||
println("rust-analyzer check is disabled");
|
||||
}
|
||||
}
|
||||
|
||||
// do help, --help [task]
|
||||
|
|
|
@ -11,7 +11,7 @@ pub fn version_in_sync() {
|
|||
let check_file = |path| {
|
||||
let file = read_to_string(path).unwrap();
|
||||
let caps = rgx.captures(&file).unwrap_or_else(|| panic!("expected usage help in `{}`", path));
|
||||
if caps.get(1).map(|c| c.as_str()).unwrap_or_default() != &version {
|
||||
if caps.get(1).map(|c| c.as_str()).unwrap_or_default() != version {
|
||||
error(format_args!(
|
||||
"usage example is outdated in `{}`\n expected `zero-ui = \"{}\"'`\n found `{}`",
|
||||
path,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use std::env;
|
||||
use std::format_args as f;
|
||||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
use std::process::{self, Command, Stdio};
|
||||
|
||||
// Command line to run `do`
|
||||
|
@ -30,7 +31,7 @@ fn cmd_impl(cmd: &str, default_args: &[&str], user_args: &[&str], envs: &[(&str,
|
|||
|
||||
let mut cmd = Command::new(cmd);
|
||||
cmd.args(&args[..]);
|
||||
cmd.envs(envs.iter().filter(|t| !t.0.is_empty() && !t.1.is_empty()).map(|&t| t));
|
||||
cmd.envs(envs.iter().filter(|t| !t.0.is_empty() && !t.1.is_empty()).copied());
|
||||
|
||||
for (remove, _) in envs.iter().filter(|t| !t.0.is_empty() && t.1.is_empty()) {
|
||||
cmd.env_remove(remove);
|
||||
|
@ -372,3 +373,7 @@ fn color(color: &str) -> &str {
|
|||
}
|
||||
}
|
||||
static mut ANSI_ENABLED: bool = false;
|
||||
|
||||
pub fn settings_path() -> PathBuf {
|
||||
std::env::current_exe().unwrap().parent().unwrap().to_owned()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue