Skip to content

Commit

Permalink
Add error message notice for missing documentation directory. Fixes #83
Browse files Browse the repository at this point in the history
…. (#125)
  • Loading branch information
daithiocrualaoich authored Jan 24, 2020
1 parent 1eeba2e commit 8228ad4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/cmd.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use crate::error::FatalError;
use cargo::core::shell::Shell;
use cargo::core::shell::Verbosity::{Normal, Quiet, Verbose};
use failure::Error;
use std::path::Path;
use std::process::Command;
use termcolor::Color::Green;

Expand All @@ -9,6 +11,13 @@ use termcolor::Color::Green;
/// only execute the command if a dry run has not been requested.
///
pub fn call(command: &[&str], path: &str, shell: &mut Shell, dry_run: bool) -> Result<bool, Error> {
if !Path::new(path).exists() {
return Err(FatalError::DocumentationPathNotPresent {
path: path.to_string(),
}
.into());
}

if dry_run {
shell.status_with_color("", format!("cd {}", path), Green)?;
shell.status_with_color("", command.join(" "), Green)?;
Expand Down
7 changes: 7 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,11 @@ pub enum FatalError {

#[fail(display = "Unknown cargo key found: {}", key)]
UnknownCargoFileKey { key: String },

#[fail(
display = "Documentation path '{}' not present. \
Was this included as argument to `sphinx-quickstart`?",
path
)]
DocumentationPathNotPresent { path: String },
}

0 comments on commit 8228ad4

Please sign in to comment.