Skip to content

Commit

Permalink
fix: ensure that -h works for all commands. fixes #506
Browse files Browse the repository at this point in the history
  • Loading branch information
justinedelson committed Sep 29, 2021
1 parent ec1a72e commit cffc4ec
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/cloudmanager-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,10 @@ async function getActiveOrganizationId (contextName) {
}

function handleError (_error, errorFn) {
if (_error.code && _error.code === 'EEXIT') {
return
}

if (cli.action.running) {
cli.action.stop('failed')
}
Expand Down
23 changes: 23 additions & 0 deletions src/hooks/prerun/help-override.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
Copyright 2021 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/

const { isThisPlugin } = require('../../cloudmanager-hook-helpers')

module.exports = function (hookOptions) {
if (!isThisPlugin(hookOptions)) {
return
}
if (hookOptions && hookOptions.argv && hookOptions.argv.includes('-h')) {
new hookOptions.Command(hookOptions.argv, hookOptions.config)._help()
this.exit()
}
}
1 change: 1 addition & 0 deletions src/hooks/prerun/prerun-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const { handleError } = require('../../cloudmanager-helpers')

module.exports = function (hookOptions) {
try {
require('./help-override').apply(this, [hookOptions])
require('./permission-info').apply(this, [hookOptions])
require('./environment-id-from-config').apply(this, [hookOptions])
require('./check-ims-context-config').apply(this, [hookOptions])
Expand Down

0 comments on commit cffc4ec

Please sign in to comment.