Compare commits

...

3 Commits

6 changed files with 73 additions and 11 deletions

View File

@ -20,18 +20,20 @@ const {
} = require ('./dist/lib/index.js'); } = require ('./dist/lib/index.js');
(async () => { (async () => {
const str = await new StringOption ({ name: 'str' }) /*
.parse (); * const str = await new StringOption ({ name: 'str' })
const bool = await new BooleanOption ({ name: 'bool' }) *.parse ();
.parse (); *const bool = await new BooleanOption ({ name: 'bool' })
const num = await new NumberOption ({ name: 'num' }) *.parse ();
.parse (); *const num = await new NumberOption ({ name: 'num' })
const arr = await new ArrayOption ({ name: 'arr' }) *.parse ();
.parse (); *const arr = await new ArrayOption ({ name: 'arr' })
*.parse ();
*/
const fld = await new FolderOption ({ name: 'fld' }) const fld = await new FolderOption ({ name: 'fld' })
.parse (); .parse ();
const data = { str, bool, num, arr, fld }; const data = { /* str, bool, num, arr,*/ fld };
console.log (data); console.log (data);
}) (); }) ();

2
Jenkinsfile vendored
View File

@ -5,7 +5,7 @@ pipeline {
VERSION = VersionNumber([ VERSION = VersionNumber([
versionNumberString: versionNumberString:
'${BUILDS_ALL_TIME}', '${BUILDS_ALL_TIME}',
versionPrefix: '2.0.', versionPrefix: '2.1.',
worstResultForIncrement: 'SUCCESS' worstResultForIncrement: 'SUCCESS'
]) ])
} }

View File

@ -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;
}
}

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 ()
);
}
}

View File

@ -2,10 +2,12 @@ import { ArraySubSource } from './ArraySubSource';
import { BooleanSubSource } from './BooleanSubSource'; import { BooleanSubSource } from './BooleanSubSource';
import { PresetSubSource } from './PresetSubSource'; import { PresetSubSource } from './PresetSubSource';
import { StringSubSource } from './StringSubSource'; import { StringSubSource } from './StringSubSource';
import { PathSubSource } from './PathSubSource';
export const sources = [ export const sources = [
ArraySubSource, ArraySubSource,
BooleanSubSource, BooleanSubSource,
PresetSubSource, PresetSubSource,
PathSubSource,
StringSubSource StringSubSource
]; ];

View File

@ -1,6 +1,6 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "es5", "target": "es6",
"module": "commonjs", "module": "commonjs",
"outDir": "./dist", "outDir": "./dist",
"rootDir": "./", "rootDir": "./",