Skip to content

Commit

Permalink
Add utility traits (#18)
Browse files Browse the repository at this point in the history
* fix: pipe stdout/stderr

* feat: add `Clone` trait for AnsiblePlaybookCommand

* feat: add Debug trait too

* feat: pipe stdin

* fix: fmt
  • Loading branch information
ce7elem authored Mar 13, 2024
1 parent 7293408 commit b1d9848
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 39 deletions.
1 change: 1 addition & 0 deletions src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ impl DefaultExecutor {

let child = Command::new(command[0].clone())
.args(&command[1..])
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()
Expand Down
26 changes: 13 additions & 13 deletions src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ impl Default for AnsibleConnectionOptions {
}

impl AnsibleConnectionOptions {
const ASK_PASS_FLAG: &str = "--ask-pass";
const CONNECTION_FLAG: &str = "--connection";
const PRIVATE_KEY_FLAG: &str = "--private-key";
const SCP_EXTRA_ARGS_FLAG: &str = "--scp-extra-args";
const SFTP_EXTRA_ARGS_FLAG: &str = "--sftp-extra-args";
const SSH_COMMON_ARGS_FLAG: &str = "--ssh-common-args";
const SSH_EXTRA_ARGS_FLAG: &str = "--ssh-extra-args";
const TIMEOUT_FLAG: &str = "--timeout";
const USER_FLAG: &str = "--user";
const ASK_PASS_FLAG: &'static str = "--ask-pass";
const CONNECTION_FLAG: &'static str = "--connection";
const PRIVATE_KEY_FLAG: &'static str = "--private-key";
const SCP_EXTRA_ARGS_FLAG: &'static str = "--scp-extra-args";
const SFTP_EXTRA_ARGS_FLAG: &'static str = "--sftp-extra-args";
const SSH_COMMON_ARGS_FLAG: &'static str = "--ssh-common-args";
const SSH_EXTRA_ARGS_FLAG: &'static str = "--ssh-extra-args";
const TIMEOUT_FLAG: &'static str = "--timeout";
const USER_FLAG: &'static str = "--user";

/// Returns a list of connection options flags to be used on
/// ansible-playbook execution
Expand Down Expand Up @@ -146,10 +146,10 @@ pub struct AnsiblePrivilegeEscalationOptions {
}

impl AnsiblePrivilegeEscalationOptions {
const ASK_BECOME_PASS_FLAG: &str = "--ask-become-pass";
const BECOME_FLAG: &str = "--become";
const BECOME_METHOD_FLAG: &str = "--become-method";
const BECOME_USER_FLAG: &str = "--become-user";
const ASK_BECOME_PASS_FLAG: &'static str = "--ask-become-pass";
const BECOME_FLAG: &'static str = "--become";
const BECOME_METHOD_FLAG: &'static str = "--become-method";
const BECOME_USER_FLAG: &'static str = "--become-user";

/// returns a list of privilege escalation options flags to be used on
/// ansible-playbook execution
Expand Down
52 changes: 26 additions & 26 deletions src/playbook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,32 +73,32 @@ impl Default for AnsiblePlaybookOptions {
}

impl AnsiblePlaybookOptions {
const ASK_VAULT_PASSWORD_FLAG: &str = "--ask-vault-password";
const CHECK_FLAG: &str = "--check";
const DIFF_FLAG: &str = "--diff";
const EXTRA_VARS_FLAG: &str = "--extra-vars";
const FLUSH_CACHE_FLAG: &str = "--flush-cache";
const FORCE_HANDLERS_FLAG: &str = "--force-handlers";
const FORKS_FLAG: &str = "--forks";
const INVENTORY_FLAG: &str = "--inventory";
const LIMIT_FLAG: &str = "--limit";
const LIST_HOSTS_FLAG: &str = "--list-hosts";
const LIST_TAGS_FLAG: &str = "--list-tags";
const LIST_TASKS_FLAG: &str = "--list-tasks";
const MODULE_PATH_FLAG: &str = "--module-path";
const SKIP_TAGS_FLAG: &str = "--skip-tags";
const START_AT_TASK_FLAG: &str = "--start-at-task";
const STEP_FLAG: &str = "--step";
const SYNTAX_CHECK_FLAG: &str = "--syntax-check";
const TAGS_FLAG: &str = "--tags";
const VAULT_ID_FLAG: &str = "--vault-id";
const VAULT_PASSWORD_FILE_FLAG: &str = "--vault-password-file";
const VERSION_FLAG: &str = "--version";
const VERBOSE_FLAG: &str = "-vvvv";
const VERBOSE_V_FLAG: &str = "-v";
const VERBOSE_VV_FLAG: &str = "-vv";
const VERBOSE_VVV_FLAG: &str = "-vvv";
const VERBOSE_VVVV_FLAG: &str = "-vvvv";
const ASK_VAULT_PASSWORD_FLAG: &'static str = "--ask-vault-password";
const CHECK_FLAG: &'static str = "--check";
const DIFF_FLAG: &'static str = "--diff";
const EXTRA_VARS_FLAG: &'static str = "--extra-vars";
const FLUSH_CACHE_FLAG: &'static str = "--flush-cache";
const FORCE_HANDLERS_FLAG: &'static str = "--force-handlers";
const FORKS_FLAG: &'static str = "--forks";
const INVENTORY_FLAG: &'static str = "--inventory";
const LIMIT_FLAG: &'static str = "--limit";
const LIST_HOSTS_FLAG: &'static str = "--list-hosts";
const LIST_TAGS_FLAG: &'static str = "--list-tags";
const LIST_TASKS_FLAG: &'static str = "--list-tasks";
const MODULE_PATH_FLAG: &'static str = "--module-path";
const SKIP_TAGS_FLAG: &'static str = "--skip-tags";
const START_AT_TASK_FLAG: &'static str = "--start-at-task";
const STEP_FLAG: &'static str = "--step";
const SYNTAX_CHECK_FLAG: &'static str = "--syntax-check";
const TAGS_FLAG: &'static str = "--tags";
const VAULT_ID_FLAG: &'static str = "--vault-id";
const VAULT_PASSWORD_FILE_FLAG: &'static str = "--vault-password-file";
const VERSION_FLAG: &'static str = "--version";
const VERBOSE_FLAG: &'static str = "-vvvv";
const VERBOSE_V_FLAG: &'static str = "-v";
const VERBOSE_VV_FLAG: &'static str = "-vv";
const VERBOSE_VVV_FLAG: &'static str = "-vvv";
const VERBOSE_VVVV_FLAG: &'static str = "-vvvv";

fn gen_verbosity(&self) -> &str {
if self.verbose {
Expand Down

0 comments on commit b1d9848

Please sign in to comment.