Compare commits

...

2 Commits

Author SHA1 Message Date
Timo 62ae2990a6 prompt will have to be self made, or extending more basic levels of enquirer 2020-06-18 13:58:38 +02:00
Timo f372e1ea17 path selector 2020-06-16 12:52:41 +02:00
6 changed files with 73 additions and 11 deletions
+11 -9
View File
@@ -20,18 +20,20 @@ const {
} = require ('./dist/lib/index.js');
(async () => {
const str = await new StringOption ({ name: 'str' })
.parse ();
const bool = await new BooleanOption ({ name: 'bool' })
.parse ();
const num = await new NumberOption ({ name: 'num' })
.parse ();
const arr = await new ArrayOption ({ name: 'arr' })
.parse ();
/*
* const str = await new StringOption ({ name: 'str' })
*.parse ();
*const bool = await new BooleanOption ({ name: 'bool' })
*.parse ();
*const num = await new NumberOption ({ name: 'num' })
*.parse ();
*const arr = await new ArrayOption ({ name: 'arr' })
*.parse ();
*/
const fld = await new FolderOption ({ name: 'fld' })
.parse ();
const data = { str, bool, num, arr, fld };
const data = { /* str, bool, num, arr,*/ fld };
console.log (data);
}) ();
Vendored
+1 -1
View File
@@ -5,7 +5,7 @@ pipeline {
VERSION = VersionNumber([
versionNumberString:
'${BUILDS_ALL_TIME}',
versionPrefix: '2.0.',
versionPrefix: '2.1.',
worstResultForIncrement: 'SUCCESS'
])
}
@@ -0,0 +1,34 @@
/* eslint-disable no-sync */
import { dirname, join, sep, basename } from 'path';
import fs from 'fs-extra';
function read_dir (dir:string, exclude_files:boolean):string[] {
const contents = fs.readdirSync (dir);
contents.unshift ('..');
if (exclude_files) {
return contents.filter ((c) => {
const full_path = join (dir, c);
try {
return fs.statSync (full_path)
.isDirectory ();
}
catch {
return false;
}
});
}
return contents;
}
interface PathPromptOptions {
starting_dir?: string;
folders_only?: boolean;
}
export class PathPrompt {
private _options: PathPromptOptions;
public constructor (options:PathPromptOptions) {
this._options = options;
}
}
+24
View File
@@ -0,0 +1,24 @@
import { InteractiveSubSource } from './InteractiveSubSource';
import { PathPrompt } from './PathCustomPrompt';
export class PathSubSource extends InteractiveSubSource {
protected condition ():boolean {
return [
'path',
'file',
'folder'
].includes (this.val.type_validation.option_type);
}
protected async run (): Promise<void> {
await this.val.assign_arg (
this.opt,
await new PathPrompt ({
message: this.get_message (),
default: this.opt.default,
folder_only: this.val.type_validation.option_type === 'folder'
})
.run ()
);
}
}
+2
View File
@@ -2,10 +2,12 @@ import { ArraySubSource } from './ArraySubSource';
import { BooleanSubSource } from './BooleanSubSource';
import { PresetSubSource } from './PresetSubSource';
import { StringSubSource } from './StringSubSource';
import { PathSubSource } from './PathSubSource';
export const sources = [
ArraySubSource,
BooleanSubSource,
PresetSubSource,
PathSubSource,
StringSubSource
];
+1 -1
View File
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es5",
"target": "es6",
"module": "commonjs",
"outDir": "./dist",
"rootDir": "./",