Skip to content
This repository was archived by the owner on Jan 22, 2019. It is now read-only.

Commit 8ef6839

Browse files
committed
feat: remove CLI commands other than default search
1 parent f19c77b commit 8ef6839

File tree

7 files changed

+10
-355
lines changed

7 files changed

+10
-355
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@
129129
"mdi-react": "^4.0.0",
130130
"mermaid": "^8.0.0-rc.8",
131131
"node-sass-import-once": "^1.2.0",
132-
"omnicli": "0.1.13",
133132
"open-color": "^1.6.3",
134133
"react": "^16.4.2",
135134
"react-dom": "^16.4.2",

src/libs/cli/config.ts

Lines changed: 0 additions & 81 deletions
This file was deleted.

src/libs/cli/featureFlags.ts

Lines changed: 0 additions & 70 deletions
This file was deleted.

src/libs/cli/file.ts

Lines changed: 0 additions & 143 deletions
This file was deleted.

src/libs/cli/index.ts

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,15 @@
1-
import * as OmniCLI from 'omnicli'
2-
3-
import configCommands from './config'
4-
import { featureFlagsCommand, toggleFeatureFlagsCommand } from './featureFlags'
5-
import fileCommand from './file'
1+
import * as omnibox from '../../browser/omnibox'
62
import searchCommand from './search'
73

8-
const commands: OmniCLI.Command[] = [...configCommands, fileCommand, featureFlagsCommand, toggleFeatureFlagsCommand]
9-
10-
const searchCli = OmniCLI.createCli({ commands: [searchCommand] })
11-
12-
const cli = OmniCLI.createCli({
13-
commands,
14-
prefix: ':',
15-
})
16-
17-
interface InitOptions {
18-
onInputEntered: (fn: (text: string, disposition: string) => void) => void
19-
onInputChanged: (fn: (text: string, suggest: (suggestions: OmniCLI.Suggestion[]) => void) => void) => void
20-
}
21-
22-
export default function initialize({ onInputEntered, onInputChanged }: InitOptions): void {
4+
export default function initialize({ onInputEntered, onInputChanged }: typeof omnibox): void {
235
onInputChanged((query, suggest) => {
24-
if (cli.hasPrefix(query)) {
25-
cli.onInputChanged(query)
26-
.then(suggest)
27-
.catch(err => console.error('error getting suggestions', err))
28-
return
29-
}
30-
31-
searchCli
32-
.onInputChanged(query)
6+
searchCommand
7+
.getSuggestions(query)
338
.then(suggest)
349
.catch(err => console.error('error getting suggestions', err))
3510
})
3611

3712
onInputEntered((query, disposition) => {
38-
if (cli.hasPrefix(query)) {
39-
cli.onInputEntered(query, disposition)
40-
return
41-
}
42-
43-
searchCli.onInputEntered(query, disposition)
13+
searchCommand.action(query, disposition)
4414
})
4515
}

src/libs/cli/search.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { first } from 'lodash'
2-
import * as OmniCLI from 'omnicli'
32

43
import storage from '../../browser/storage'
54
import * as tabs from '../../browser/tabs'
@@ -10,18 +9,15 @@ import { buildSearchURLQuery } from '../../shared/util/url'
109

1110
const isURL = /^https?:\/\//
1211

13-
class SearchCommand implements OmniCLI.Command {
14-
public name = OmniCLI.DEFAULT_NAME
12+
class SearchCommand {
1513
public description = 'Enter a search query'
1614

1715
private suggestionFetcher = createSuggestionFetcher(20)
1816

19-
private prev: { query: string; suggestions: OmniCLI.Suggestion[] } = { query: '', suggestions: [] }
17+
private prev: { query: string; suggestions: chrome.omnibox.Suggestion[] } = { query: '', suggestions: [] }
2018

21-
public getSuggestions = (args: string[]): Promise<OmniCLI.Suggestion[]> => {
22-
const query = args.join(' ')
23-
24-
return new Promise(resolve => {
19+
public getSuggestions = (query: string): Promise<chrome.omnibox.Suggestion[]> =>
20+
new Promise(resolve => {
2521
if (this.prev.query === query) {
2622
resolve(this.prev.suggestions)
2723
return
@@ -44,11 +40,8 @@ class SearchCommand implements OmniCLI.Command {
4440
},
4541
})
4642
})
47-
}
48-
49-
public action = (args: string[], disposition?: string): void => {
50-
const query = args.join(' ')
5143

44+
public action = (query: string, disposition?: string): void => {
5245
storage.getSync(({ serverUrls, sourcegraphURL }) => {
5346
const url = sourcegraphURL || first(serverUrls)
5447
const props = {

0 commit comments

Comments
 (0)