-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit 10c4758
Showing
5 changed files
with
2,365 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const test = Deno.test; | ||
export { parse } from 'https://deno.land/std/flags/mod.ts'; | ||
export { blue, bold, green, red, yellow } from 'https://deno.land/std/fmt/colors.ts'; | ||
export { assert, assertEquals, assertThrows, assertThrowsAsync } from 'https://deno.land/std/testing/asserts.ts'; |
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,77 @@ | ||
import Denomander from 'https://deno.land/x/denomander/mod.ts'; | ||
import { blue, green, red } from './deps.ts'; | ||
|
||
const program = new Denomander({ | ||
app_name: 'My MY App', | ||
app_description: 'My MY Description', | ||
app_version: '1.0.1', | ||
errors: { | ||
INVALID_RULE: 'Invalid Rule', | ||
OPTION_NOT_FOUND: 'Option not found!', | ||
COMMAND_NOT_FOUND: 'Command not found!', | ||
REQUIRED_OPTION_NOT_FOUND: 'Required option is not specified!', | ||
REQUIRED_VALUE_NOT_FOUND: 'Required command value is not specified!', | ||
TOO_MANY_PARAMS: 'You have passed too many parameters', | ||
}, | ||
}); | ||
|
||
program.baseOption('-q --quiet', 'Do not output any message').globalOption('-c --color', 'Define the output color'); | ||
|
||
program | ||
.command('serve', 'Start the server') | ||
.alias('superserve', 'master-server') | ||
.requiredOption('-p --port', 'Define the port') | ||
.action(() => { | ||
colored_output('http://localhost:' + program.port); | ||
}); | ||
|
||
program | ||
.command('clone [foldername]') | ||
.action(({ foldername }: any) => { | ||
colored_output('The repo is cloned into: ' + foldername); | ||
}) | ||
.description('clone a repo'); | ||
|
||
program | ||
.command('mv [from] [to] [message?]') | ||
.action(({ from, to, message }: any) => { | ||
colored_output(`File is moved from ${from} to ${to}`); | ||
if (message) { | ||
console.log(message); | ||
} | ||
}) | ||
.description('move file'); | ||
|
||
program.on('quiet', () => { | ||
console.log('Enable Quiet Mode...'); | ||
}); | ||
|
||
try { | ||
program.parse(Deno.args); | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
|
||
function colored_output(text: string) { | ||
if (program.color) { | ||
switch (program.color) { | ||
case 'red': | ||
console.log(red(text)); | ||
break; | ||
|
||
case 'green': | ||
console.log(green(text)); | ||
break; | ||
|
||
case 'blue': | ||
console.log(blue(text)); | ||
break; | ||
|
||
default: | ||
console.log(text); | ||
break; | ||
} | ||
} else { | ||
console.log(text); | ||
} | ||
} |
Oops, something went wrong.