Skip to content

Commit

Permalink
some small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAlan404 committed Nov 15, 2023
1 parent 944107f commit de61875
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 8 deletions.
6 changes: 5 additions & 1 deletion src/app/feedback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,12 @@ impl App {
)))
}

Check warning on line 65 in src/app/feedback.rs

View workflow job for this annotation

GitHub Actions / clippy

this function's return value is unnecessary

warning: this function's return value is unnecessary --> src/app/feedback.rs:59:5 | 59 | / pub fn print_job(&self, job: &str) -> Result<()> { 60 | | Ok(self.multi_progress.suspend(|| println!( 61 | | "{} {}", 62 | | ColorfulTheme::default().active_item_prefix, 63 | | style(job).cyan().bold() 64 | | ))) 65 | | } | |_____^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_wraps help: remove the return type... | 59 | pub fn print_job(&self, job: &str) -> Result<()> { | ~~~~~~~~~~ help: ...and then remove returned values | 60 - Ok(self.multi_progress.suspend(|| println!( 61 - "{} {}", 62 - ColorfulTheme::default().active_item_prefix, 63 - style(job).cyan().bold() 64 - ))) 60 + |

pub fn is_ci(&self) -> bool {

Check warning on line 67 in src/app/feedback.rs

View workflow job for this annotation

GitHub Actions / clippy

unused `self` argument

warning: unused `self` argument --> src/app/feedback.rs:67:18 | 67 | pub fn is_ci(&self) -> bool { | ^^^^^ | = help: consider refactoring to an associated function = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_self = note: `#[warn(clippy::unused_self)]` implied by `#[warn(clippy::pedantic)]`
std::env::var("CI").ok() == Some("true".to_owned())
}

pub fn ci(&self, cmd: &str) {
if std::env::var("CI").ok() == Some("true".to_owned()) {
if self.is_ci() {
self.multi_progress.suspend(|| println!("{cmd}"))

Check warning on line 73 in src/app/feedback.rs

View workflow job for this annotation

GitHub Actions / clippy

consider adding a `;` to the last statement for consistent formatting

warning: consider adding a `;` to the last statement for consistent formatting --> src/app/feedback.rs:73:13 | 73 | self.multi_progress.suspend(|| println!("{cmd}")) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `self.multi_progress.suspend(|| println!("{cmd}"));` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
}
}
Expand Down
21 changes: 17 additions & 4 deletions src/core/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,13 @@ impl<'a> BuildContext<'a> {
pb.set_message(diffed_paths.to_string_lossy().to_string());

self.bootstrap_file(&diffed_paths, lockfile_entries.get(&diffed_paths)).await.context(format!(
"Bootstrapping file: {}",
entry.path().display()
"Bootstrapping file:
- Entry: {}
- Destination: {}
- Relative: {}",
entry.path().display(),
dest.display(),
diffed_paths.display()
))?;
}

Expand Down Expand Up @@ -89,7 +94,7 @@ impl<'a> BuildContext<'a> {
"properties", "txt", "yaml", "yml", "conf", "config", "toml", "json", "json5", "secret"
];

Check failure on line 95 in src/core/bootstrap.rs

View workflow job for this annotation

GitHub Actions / clippy

useless use of `vec!`

error: useless use of `vec!` --> src/core/bootstrap.rs:93:30 | 93 | let bootstrap_exts = vec![ | ______________________________^ 94 | | "properties", "txt", "yaml", "yml", "conf", "config", "toml", "json", "json5", "secret" 95 | | ]; | |_________^ help: you can use an array directly: `["properties", "txt", "yaml", "yml", "conf", "config", "toml", "json", "json5", "secret"]` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_vec = note: `#[deny(clippy::useless_vec)]` implied by `#[deny(clippy::all)]`

bootstrap_exts.contains(&ext)
bootstrap_exts.contains(&ext) || self.app.server.options.bootstrap_exts.contains(&ext.to_string())
}

pub async fn bootstrap_file(
Expand All @@ -102,7 +107,15 @@ impl<'a> BuildContext<'a> {
let source = self.app.server.path.join("config").join(rel_path);
let dest = self.output_dir.join(rel_path);

let metadata = fs::metadata(&source).await?;
let metadata = fs::metadata(&source).await
.context(format!(
"Getting metadata
- File: {}
- Relative path: {pretty_path}
- Destination: {}",
source.display(),
dest.display(),
))?;

if self.force || {
if let Some(time) = cache {
Expand Down
7 changes: 4 additions & 3 deletions src/hot_reload/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ impl<'a> DevSession<'a> {
async fn handle_commands(mut self, mut rx: mpsc::Receiver<Command>, mut tx: mpsc::Sender<Command>) -> Result<()> {
let mp = self.builder.app.multi_progress.clone();

self.builder.app.ci("::group::Starting server process");

let mut child: Option<Child> = None;
let mut stdout_lines: Option<tokio::io::Lines<BufReader<tokio::process::ChildStdout>>> = None;

Expand All @@ -109,6 +107,7 @@ impl<'a> DevSession<'a> {
Some(cmd) = rx.recv() => {
match cmd {
Command::Start => {
self.builder.app.ci("::group::Starting server process");
self.builder.app.info("Starting server process...")?;
if child.is_none() {
let mut spawned_child = self.spawn_child().await?;
Expand All @@ -117,6 +116,7 @@ impl<'a> DevSession<'a> {
}
}
Command::Stop => {
self.builder.app.ci("::endgroup::");
self.builder.app.info("Killing server process...")?;
if let Some(ref mut child) = &mut child {
child.kill().await?;
Expand Down Expand Up @@ -195,6 +195,7 @@ impl<'a> DevSession<'a> {
}
Command::EndSession => {
self.builder.app.info("Ending session...")?;
self.builder.app.ci("::endgroup::");
break 'l;
}
}
Expand Down Expand Up @@ -242,6 +243,7 @@ impl<'a> DevSession<'a> {
},
Ok(Some(status)) = try_wait_child(&mut child) => {
exit_status = Some(status);
self.builder.app.ci("::endgroup::");
self.builder.app.info("Server process exited")?;

is_stopping = false;
Expand Down Expand Up @@ -378,7 +380,6 @@ impl<'a> DevSession<'a> {
Ok(())
}

Check warning on line 381 in src/hot_reload/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

this function has too many lines (254/100)

warning: this function has too many lines (254/100) --> src/hot_reload/mod.rs:92:5 | 92 | / async fn handle_commands(mut self, mut rx: mpsc::Receiver<Command>, mut tx: mpsc::Sender<Command>) -> Result<()> { 93 | | let mp = self.builder.app.multi_progress.clone(); 94 | | 95 | | let mut child: Option<Child> = None; ... | 380 | | Ok(()) 381 | | } | |_____^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_lines


pub fn create_hotreload_watcher(
config: Arc<Mutex<HotReloadConfig>>,
_tx: mpsc::Sender<Command>,

Check warning on line 385 in src/hot_reload/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

this argument is passed by value, but not consumed in the function body

warning: this argument is passed by value, but not consumed in the function body --> src/hot_reload/mod.rs:385:14 | 385 | _tx: mpsc::Sender<Command>, | ^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead: `&mpsc::Sender<Command>` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_value
Expand Down
3 changes: 3 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ enum Commands {

#[tokio::main]
async fn main() -> Result<()> {
if std::env::var("CI") == Ok("true".to_owned()) {
println!("::endgroup::");
}
let args = CLI::parse();

let mut base_app = BaseApp::new()?;
Expand Down
2 changes: 2 additions & 0 deletions src/model/servertoml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ pub struct Server {
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq)]
pub struct ServerOptions {
pub upload_to_mclogs: bool,
#[serde(skip_serializing_if = "Vec::is_empty")]
pub bootstrap_exts: Vec<String>,
}

impl Server {
Expand Down

0 comments on commit de61875

Please sign in to comment.