-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Move endpoint commands into a topic, with aliases to the old commands * Fix warning and log messages to use capitals and period * Add tests for the remaining endpoint commands * Fix linter things * Update to 'Compute the frustum of the wangledinger' (imperative mood)
- Loading branch information
Showing
8 changed files
with
213 additions
and
142 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Command } from "@oclif/core"; | ||
import { ShellConfig } from "../../lib/config"; | ||
import chalk from "chalk"; | ||
|
||
export default class ListEndpointCommand extends Command { | ||
static flags = {}; | ||
|
||
static description = "List endpoints in ~/.fauna-shell."; | ||
|
||
static examples = ["$ fauna endpoint list"]; | ||
|
||
static aliases = ["list-endpoints"]; | ||
static deprecateAliases = true; | ||
|
||
async run() { | ||
const config = ShellConfig.read({}); | ||
|
||
await this.execute(config); | ||
} | ||
|
||
async execute(config: ShellConfig) { | ||
await this.parse(); | ||
|
||
this.log("Available endpoints:"); | ||
for (const key of Object.keys(config.rootConfig.endpoints)) { | ||
if (config.rootConfig.defaultEndpoint === key) { | ||
this.log(chalk.green("* ") + key); | ||
} else { | ||
this.log(" " + key); | ||
} | ||
} | ||
} | ||
} |
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,45 @@ | ||
import { Args, Command } from "@oclif/core"; | ||
import { ShellConfig } from "../../lib/config"; | ||
|
||
export default class RemoveEndpointCommand extends Command { | ||
static description = "Remove an endpoint from ~/.fauna-shell."; | ||
|
||
static examples = ["$ fauna endpoint remove my_endpoint"]; | ||
|
||
static flags = {}; | ||
|
||
static args = { | ||
name: Args.string({ | ||
required: true, | ||
description: "Endpoint name", | ||
}), | ||
}; | ||
|
||
static aliases = ["delete-endpoint"]; | ||
static deprecateAliases = true; | ||
|
||
async run() { | ||
const config = ShellConfig.read({}); | ||
|
||
await this.execute(config); | ||
} | ||
|
||
async execute(config: ShellConfig) { | ||
const { args } = await this.parse(); | ||
const name = args.name; | ||
|
||
if (config.rootConfig.endpoints[name] === undefined) { | ||
this.error(`No such endpoint ${name}`); | ||
} | ||
|
||
// Clear the default if `name` is the default. | ||
if (config.rootConfig.defaultEndpoint === name) { | ||
config.rootConfig.defaultEndpoint = undefined; | ||
} | ||
delete config.rootConfig.endpoints[name]; | ||
|
||
config.saveRootConfig(); | ||
|
||
this.log(`Removed endpoint ${name}.`); | ||
} | ||
} |
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
Oops, something went wrong.