Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
shashankbrgowda committed Sep 18, 2024
1 parent 3da532b commit 2fb5ce2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
25 changes: 12 additions & 13 deletions packages/apollo-cli/src/commands/jbrowse/set-config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as fs from 'node:fs'
import {
ImportJBrowseConfigChange,
JBrowseConfig,
type JBrowseConfig,
type SerializedImportJBrowseConfigChange,
} from '@apollo-annotation/shared'
import { Flags } from '@oclif/core'
import { Args } from '@oclif/core'
import { Agent, RequestInit, fetch } from 'undici'
import { ConfigError } from '../../ApolloConf.js'
import { BaseCommand } from '../../baseCommand.js'
Expand All @@ -22,35 +22,34 @@ export default class SetConfig extends BaseCommand<typeof SetConfig> {
static examples = [
{
description: 'Add jbrowse configuration:',
command: '<%= config.bin %> <%= command.id %> -i config.json',
command: '<%= config.bin %> <%= command.id %> config.json',
},
]

static flags = {
'input-file': Flags.string({
char: 'i',
static args = {
inputFile: Args.string({
description: 'Input jbrowse configuration file',
required: true,
}),
}

async run(): Promise<void> {
const { flags } = await this.parse(SetConfig)
const { args, flags } = await this.parse(SetConfig)

if (!fs.existsSync(flags['input-file'])) {
this.error(`File ${flags['input-file']} does not exist`)
if (!fs.existsSync(args.inputFile)) {
this.error(`File ${args.inputFile} does not exist`)
}

const access: { address: string; accessToken: string } =
await this.getAccess(flags['config-file'], flags.profile)
const filehandle = await fs.promises.open(flags['input-file'])
const filehandle = await fs.promises.open(args.inputFile)
const fileContent = await filehandle.readFile({ encoding: 'utf8' })
await filehandle.close()

const change = new ImportJBrowseConfigChange({
const change: SerializedImportJBrowseConfigChange = {
typeName: 'ImportJBrowseConfigChange',
newJBrowseConfig: JSON.parse(fileContent) as JBrowseConfig,
})
}

const auth: RequestInit = {
method: 'POST',
Expand Down
16 changes: 9 additions & 7 deletions packages/website/docs/cli/jbrowse.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Get Jbrowse configuration from Apollo

- [`apollo jbrowse get-config`](#apollo-jbrowse-get-config)
- [`apollo jbrowse set-config`](#apollo-jbrowse-set-config)
- [`apollo jbrowse set-config INPUTFILE`](#apollo-jbrowse-set-config-inputfile)

## `apollo jbrowse get-config`

Expand All @@ -26,18 +26,20 @@ DESCRIPTION
_See code:
[src/commands/jbrowse/get-config.ts](https://github.com/GMOD/Apollo3/blob/v0.1.19/packages/apollo-cli/src/commands/jbrowse/get-config.ts)_

## `apollo jbrowse set-config`
## `apollo jbrowse set-config INPUTFILE`

Add jbrowse configuration

```
USAGE
$ apollo jbrowse set-config -i <value> [--profile <value>] [--config-file <value>]
$ apollo jbrowse set-config INPUTFILE [--profile <value>] [--config-file <value>]
ARGUMENTS
INPUTFILE Input jbrowse configuration file
FLAGS
-i, --input-file=<value> (required) Input jbrowse configuration file
--config-file=<value> Use this config file (mostly for testing)
--profile=<value> Use credentials from this profile
--config-file=<value> Use this config file (mostly for testing)
--profile=<value> Use credentials from this profile
DESCRIPTION
Add jbrowse configuration
Expand All @@ -47,7 +49,7 @@ DESCRIPTION
EXAMPLES
Add jbrowse configuration:
$ apollo jbrowse set-config -i config.json
$ apollo jbrowse set-config config.json
```

_See code:
Expand Down

0 comments on commit 2fb5ce2

Please sign in to comment.