-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
73 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
# `pitchfork disable` | ||
|
||
- **Usage**: `pitchfork disable` | ||
- **Usage**: `pitchfork disable <ID>` | ||
- **Aliases**: `d` | ||
|
||
Prevent a daemon from restarting | ||
|
||
## Arguments | ||
|
||
### `<ID>` | ||
|
||
Name of the daemon to disable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
# `pitchfork enable` | ||
|
||
- **Usage**: `pitchfork enable` | ||
- **Usage**: `pitchfork enable <ID>` | ||
- **Aliases**: `e` | ||
|
||
Allow a daemon to start | ||
|
||
## Arguments | ||
|
||
### `<ID>` | ||
|
||
Name of the daemon to enable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,26 @@ | ||
use crate::state_file::StateFile; | ||
use crate::Result; | ||
use miette::bail; | ||
|
||
/// Prevent a daemon from restarting | ||
#[derive(Debug, clap::Args)] | ||
#[clap(visible_alias = "d", verbatim_doc_comment)] | ||
pub struct Disable {} | ||
pub struct Disable { | ||
/// Name of the daemon to disable | ||
id: String, | ||
} | ||
|
||
impl Disable { | ||
pub async fn run(&self) -> Result<()> { | ||
let mut sf = StateFile::get().clone(); | ||
if self.id == "pitchfork" { | ||
bail!("Cannot disable pitchfork daemon"); | ||
} | ||
let disabled = sf.disabled.insert(self.id.clone()); | ||
if disabled { | ||
sf.write()?; | ||
println!("disabled {}", self.id); | ||
} | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,26 @@ | ||
use crate::state_file::StateFile; | ||
use crate::Result; | ||
use miette::bail; | ||
|
||
/// Allow a daemon to start | ||
#[derive(Debug, clap::Args)] | ||
#[clap(visible_alias = "e", verbatim_doc_comment)] | ||
pub struct Enable {} | ||
pub struct Enable { | ||
/// Name of the daemon to enable | ||
id: String, | ||
} | ||
|
||
impl Enable { | ||
pub async fn run(&self) -> Result<()> { | ||
let mut sf = StateFile::get().clone(); | ||
if self.id == "pitchfork" { | ||
bail!("Cannot disable pitchfork daemon"); | ||
} | ||
let enabled = sf.disabled.remove(&self.id); | ||
if enabled { | ||
sf.write()?; | ||
println!("enabled {}", self.id); | ||
} | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters