diff --git a/src/commands/deploy.ts b/src/commands/deploy.ts index ad9b509..4a61ae6 100644 --- a/src/commands/deploy.ts +++ b/src/commands/deploy.ts @@ -1,24 +1,37 @@ import AnsibleCmd from '../base-cmd-ansible-abstract' +import {flags} from '@oclif/command' export default class DeployCmd extends AnsibleCmd { static description = 'Setup an app with Ansible playbooks.' static examples = [ - '$ ce-dev deploy example-app', + '$ ce-dev deploy example-app --verbose', ] + static flags = { + help: flags.help({char: 'h'}), + verbose: flags.boolean({ + char: 'v', + description: 'Enable verbose output in Ansible.', + }), + } + protected ansibleProjectPlaybooksPath = '/home/ce-dev/projects-playbooks/deploy' protected ansibleScriptsPath = '/home/ce-dev/ce-deploy' protected ansibleScript = 'scripts/deploy.sh' + protected verbose = false + /** * @inheritdoc */ public constructor(argv: string[], config: any) { super(argv, config) + const {flags} = this.parse(DeployCmd) this.ansiblePaths = this.activeProjectInfo.deploy + if (flags.verbose) this.verbose = true } protected getCommandParameters(ansiblePath: string): string { @@ -26,7 +39,8 @@ export default class DeployCmd extends AnsibleCmd { const buildId = this.activeProjectInfo.project_name const ownBranch = '1.x' const configBranch = '1.x' - const cmd = '--own-branch ' + ownBranch + ' --config-branch ' + configBranch + ' --workspace ' + workspace + ' --build-id ' + buildId + ' --playbook ' + ansiblePath + ' --build-number 1 --previous-stable-build-number 1 --ansible-extra-vars \'{"is_local":"true"}\'' + let cmd = '--own-branch ' + ownBranch + ' --config-branch ' + configBranch + ' --workspace ' + workspace + ' --build-id ' + buildId + ' --playbook ' + ansiblePath + ' --build-number 1 --previous-stable-build-number 1 --ansible-extra-vars \'{"is_local":"true"}\'' + if (this.verbose) cmd += ' --verbose' return cmd } } diff --git a/src/commands/provision.ts b/src/commands/provision.ts index ae6f490..12a09d2 100644 --- a/src/commands/provision.ts +++ b/src/commands/provision.ts @@ -5,7 +5,7 @@ export default class ProvisionCmd extends AnsibleCmd { static description = 'Provision containers with Ansible playbooks.' static examples = [ - '$ ce-dev provision --branch 1.x --config 1.x', + '$ ce-dev provision --branch 1.x --config 1.x --verbose', ] static flags = { @@ -20,6 +20,10 @@ export default class ProvisionCmd extends AnsibleCmd { description: 'The branch of the ce-provision-config repository. See https://github.com/codeenigma/ce-dev-ce-provision-config for options.', default: '1.x', }), + verbose: flags.boolean({ + char: 'v', + description: 'Enable verbose output in Ansible.', + }), } protected ansibleProjectPlaybooksPath = '/home/ce-dev/projects-playbooks/provision' @@ -32,6 +36,8 @@ export default class ProvisionCmd extends AnsibleCmd { protected configBranch = '1.x' + protected verbose = false + /** * @inheritdoc */ @@ -41,12 +47,14 @@ export default class ProvisionCmd extends AnsibleCmd { this.ansiblePaths = this.activeProjectInfo.provision this.ownBranch = flags.branch this.configBranch = flags.config + if (flags.verbose) this.verbose = true } protected getCommandParameters(ansiblePath: string): string { const workspace = this.ansibleProjectPlaybooksPath const repo = this.activeProjectInfo.project_name let cmd = '--own-branch ' + this.ownBranch + if (this.verbose) cmd += ' --verbose' cmd += ' --config-branch ' + this.configBranch cmd += ' --workspace ' + workspace cmd += ' --repo ' + repo