cli-stash
Version:
CLI application to manage and work with Atlassian Stash. Work with your Stash project and repositories from Command lines.
66 lines (65 loc) • 2.27 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.UX = void 0;
const core_1 = require("@oclif/core");
const notifier = require("node-notifier");
const strUtils_1 = require("../utils/strUtils");
class UX {
constructor(flags) {
this.flags = flags || {};
}
startSpinner(message) {
core_1.CliUx.ux.action.start(message);
}
stopSpinner(message) {
core_1.CliUx.ux.action.stop(message);
}
log(message) {
if (!this.flags.json) {
console.log(message);
}
}
table(data, columns, options = {}) {
if (!this.flags.json) {
core_1.CliUx.ux.table(data, columns, options);
}
}
prompt(text, options) {
return core_1.CliUx.ux.prompt(text, options);
}
notify(title, message) {
notifier.notify({
title: title,
message: message
});
}
static processDocumentation(desc) {
const readmeURL = 'https://github.com/JJLongoria/stash-cli/blob/main/README.md';
if (desc) {
if (strUtils_1.StrUtils.containsIgnorecase(desc, '<doc:')) {
const docData = desc.substring(desc.indexOf('<doc:'), desc.indexOf('>') + 1);
let doctype = strUtils_1.StrUtils.replace(docData, '<doc:', '');
doctype = strUtils_1.StrUtils.replace(doctype, '>', '');
const message = 'See the JSON Schema on: ' + readmeURL + '#' + doctype.toLowerCase();
desc = strUtils_1.StrUtils.replace(desc, docData, message);
}
return desc;
}
return undefined;
}
static cannotUseWith(flags) {
let convertedFlags = [];
for (const flag of flags) {
convertedFlags.push('--' + flag);
}
return 'Cannot use with ' + convertedFlags.join(', ') + ' flag' + (flags.length > 1 ? 's' : '');
}
static dependsOn(flags) {
let convertedFlags = [];
for (const flag of flags) {
convertedFlags.push('--' + flag);
}
return 'Depends on ' + convertedFlags.join(', ') + ' flag' + (flags.length > 1 ? 's' : '');
}
}
exports.UX = UX;