-
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.
[cli] Remove meow and use own cli framework #5
- add .ayi.yml to use Ayi test instead of npm run ft - add cmd folder - don't load config by default, should do it before executing a callback
- Loading branch information
Showing
10 changed files
with
88 additions
and
51 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,2 @@ | ||
test: | ||
- npm run ft |
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 |
---|---|---|
@@ -1,5 +1,12 @@ | ||
#!/usr/bin/env node | ||
|
||
'use strict'; | ||
const cli = require('../lib/cli'); | ||
cli.run(); | ||
// const cli = require('../lib/cli'); | ||
// cli.run(); | ||
|
||
const Cli = require('../lib/cli/app'); | ||
const rootCmd = require('../cmd/root'); | ||
|
||
let app = new Cli(); | ||
app.setRootCmd(rootCmd); | ||
app.run(); |
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,16 @@ | ||
/** | ||
* Created by at15 on 2016/9/11. | ||
*/ | ||
'use strict'; | ||
|
||
const Command = require('../lib/cli/command'); | ||
const versionCmd = require('./version'); | ||
|
||
let rootCmd = new Command(); | ||
rootCmd.name = 'about-cli'; | ||
rootCmd.registerCommand(versionCmd); | ||
rootCmd.setFunc(() => { | ||
console.log('I should show some help'); | ||
}); | ||
|
||
module.exports = rootCmd; |
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,15 @@ | ||
/** | ||
* Created by at15 on 2016/9/10. | ||
*/ | ||
'use strict'; | ||
|
||
const Command = require('../lib/cli/command'); | ||
const version = require('../lib/constant').VERSION; | ||
|
||
let versionCmd = new Command(); | ||
versionCmd.name = 'version'; | ||
versionCmd.setFunc(() => { | ||
console.log(version); | ||
}); | ||
|
||
module.exports = versionCmd; |
This file was deleted.
Oops, something went wrong.
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,9 @@ | ||
/** | ||
* Created by at15 on 2016/9/10. | ||
*/ | ||
'use strict'; | ||
|
||
module.exports = { | ||
VERSION: '0.0.1', | ||
DEFAULT_CONFIG_FILE: '.about.yml' | ||
}; |
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 |
---|---|---|
|
@@ -19,7 +19,6 @@ describe('Command', ()=> { | |
expect(rootCmd.subCommands).to.have.property(subCmd.name); | ||
let subCmdWithoutName = new Command(); | ||
expect(rootCmd.registerCommand(subCmdWithoutName)).to.eqls(false); | ||
|
||
}); | ||
|
||
it('can execute callback function', (done) => { | ||
|
@@ -48,4 +47,23 @@ describe('Command', ()=> { | |
rootCmd.registerCommand(gitCmd); | ||
rootCmd.execute(null, ['git', 'status'], {verbose: true}); | ||
}); | ||
|
||
it('non root cmd can have sub command', (done) => { | ||
let rootCmd = new Command(); | ||
rootCmd.name = 'dummy'; | ||
let gitCmd = new Command(); | ||
gitCmd.name = 'git'; | ||
let cloneCmd = new Command(); | ||
cloneCmd.name = 'clone'; | ||
let cloneURL = '[email protected]/tongquhq/about.git'; | ||
gitCmd.registerCommand(cloneCmd); | ||
rootCmd.registerCommand(gitCmd); | ||
cloneCmd.setFunc((app, args, flags) => { | ||
expect(app).to.eql(null); | ||
expect(args).to.eql([cloneURL]); | ||
expect(flags).to.eql({verbose: true}); | ||
done(); | ||
}); | ||
rootCmd.execute(null, ['git', 'clone', cloneURL], {verbose: true}); | ||
}); | ||
}); |