-
Notifications
You must be signed in to change notification settings - Fork 24
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
1 parent
ebba926
commit 70773b0
Showing
50 changed files
with
953 additions
and
726 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
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
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// @ts-check | ||
import * as base from '../utils/base.js' | ||
import * as btp from '../utils/btp.js' | ||
const colors = base.colors | ||
|
||
export const command = 'btpInfo' | ||
export const aliases = ['btpinfo'] | ||
export const describe = base.bundle.getText("btpInfo") | ||
|
||
export const builder = base.getBuilder({ | ||
output: { | ||
alias: ['o', 'Output'], | ||
choices: ["tbl", "json"], | ||
default: "tbl", | ||
type: 'string', | ||
desc: base.bundle.getText("outputType") | ||
} | ||
}, false) | ||
|
||
|
||
export async function handler(argv) { | ||
base.promptHandler(argv, getBTPInfo, { | ||
output: { | ||
description: base.bundle.getText("outputType"), | ||
type: 'string', | ||
// validator: /t[bl]*|s[ql]*|c[ds]?/, | ||
required: true | ||
} | ||
}) | ||
} | ||
|
||
export async function getBTPInfo(prompts) { | ||
base.debug('getBTPInfo') | ||
base.startSpinnerInt() | ||
base.debug(prompts) | ||
try { | ||
base.setPrompts(prompts) | ||
|
||
let data = await btp.getBTPConfig() | ||
base.stopSpinnerInt() | ||
if(prompts.output === 'json'){ | ||
console.log(data) | ||
}else{ | ||
console.log(`${base.bundle.getText("dbx.user")}: ${colors.green(data.UserName)}`) | ||
console.log(`${base.bundle.getText("btp.ServerURL")}: ${colors.blue(data.ServerURL)}`) | ||
console.log(`${base.bundle.getText("btp.version")}: ${colors.green(data.Version)}`) | ||
for (let item of data.TargetHierarchy) { | ||
let output = '' | ||
if(item.Type === 'globalaccount'){ | ||
output = base.bundle.getText("btp.globalaccount") | ||
}else if(item.Type === 'directory'){ | ||
output = base.bundle.getText("btp.folder") | ||
}else if(item.Type === 'subaccount'){ | ||
output = base.bundle.getText("btp.subaccount") | ||
} | ||
console.log(`${output}: ${colors.green(item.DisplayName)} ${colors.red(item.ID)}`) | ||
} | ||
} | ||
return base.end() | ||
} catch (error) { | ||
base.error(error) | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// @ts-check | ||
import * as base from '../utils/base.js' | ||
import * as btp from '../utils/btp.js' | ||
const colors = base.colors | ||
|
||
export const command = 'sub' | ||
export const aliases = ['subs', 'Sub', 'Subs', 'btpsub', 'btpsubs', 'btpSub', 'btpSubs', 'btpsubscriptions', 'btpSubscriptions'] | ||
export const describe = base.bundle.getText("btpSub") | ||
|
||
export const builder = base.getBuilder({}, false) | ||
|
||
|
||
export async function handler(argv) { | ||
base.promptHandler(argv, getSubs, {}) | ||
} | ||
|
||
export async function getSubs(prompts) { | ||
base.debug('getSubs') | ||
base.startSpinnerInt() | ||
base.debug(prompts) | ||
try { | ||
base.setPrompts(prompts) | ||
|
||
let subs = await btp.getBTPSubscriptions() | ||
base.stopSpinnerInt() | ||
const subscribed = 'SUBSCRIBED' | ||
for (let item of subs.applications) { | ||
if (item.state === subscribed) { | ||
console.log(item.displayName) | ||
if (item.subscriptionUrl) { | ||
console.log(colors.blue(item.subscriptionUrl)) | ||
} | ||
} | ||
} | ||
|
||
return base.end() | ||
} catch (error) { | ||
base.error(error) | ||
} | ||
} |
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
Oops, something went wrong.