-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #209 from IgniteUI/vslavov/66-doc-command
feat: add doc command #66
- Loading branch information
Showing
8 changed files
with
1,131 additions
and
276 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
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,39 @@ | ||
import * as opn from "opn"; | ||
import { PromptSession } from "../PromptSession"; | ||
import { Util } from "../Util"; | ||
|
||
let doc: { | ||
[term: string]: any, | ||
execute: (argv: any) => Promise<void> | ||
}; | ||
doc = { | ||
// tslint:disable:object-literal-sort-keys | ||
command: "doc [term]", | ||
desc: "opens the Infragistics search for the given term", | ||
builder: { | ||
term: { | ||
describe: "The term you would like to search for", | ||
type: "string" | ||
} | ||
}, | ||
template: null, | ||
open(target) { | ||
opn(target); | ||
}, | ||
async execute(argv) { | ||
if (!argv.term) { | ||
const answer = await PromptSession.chooseTerm(); | ||
argv.term = answer; | ||
await this.execute(argv); | ||
} else if (!Util.isAlphanumericExt(argv.term)) { | ||
return Util.error(`The search term '${argv.term}' is not valid.` + "\n" + | ||
"Name should start with a letter and can also contain numbers, dashes and spaces.", | ||
"red"); | ||
} else { | ||
Util.log(`Review your search results in the browser`, "green"); | ||
doc.open(`https://www.infragistics.com/search?q=${argv.term.trim()}`); | ||
} | ||
} | ||
}; | ||
|
||
export default doc; |
Oops, something went wrong.