-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
27ff5a4
commit 47c7bc3
Showing
2 changed files
with
31 additions
and
29 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 |
---|---|---|
@@ -1,27 +1,31 @@ | ||
import { Command, flags } from "@oclif/command" | ||
import Gravity from "../lib/gravity" | ||
|
||
export default class Identify extends Command { | ||
static description = "describe the command here" | ||
|
||
static flags = { | ||
help: flags.help({ char: "h" }), | ||
// flag with a value (-n, --name=VALUE) | ||
name: flags.string({ char: "n", description: "name to print" }), | ||
// flag with no value (-f, --force) | ||
force: flags.boolean({ char: "f" }), | ||
} | ||
|
||
static args = [{ name: "file" }] | ||
static args = [{ name: "id" }] | ||
|
||
static collectionsToCheck = [ | ||
{ name: "Artwork", endpoint: "artwork" }, | ||
{ name: "Artist", endpoint: "artist" }, | ||
] | ||
|
||
async run() { | ||
const { args, flags } = this.parse(Identify) | ||
const gravity = new Gravity() | ||
const { args } = this.parse(Identify) | ||
const { id } = args | ||
|
||
const name = flags.name || "world" | ||
this.log( | ||
`hello ${name} from /Users/roop/Projects/artsy-cli/src/commands/identify.ts` | ||
) | ||
if (args.file && flags.force) { | ||
this.log(`you input --force and --file: ${args.file}`) | ||
} | ||
Identify.collectionsToCheck.forEach(async collection => { | ||
const resource = `${collection.endpoint}/${id}` | ||
const response = await gravity.get(resource) | ||
if (response.status === 200) { | ||
this.log(`${collection.name} ${gravity.url(resource)}`) | ||
} | ||
}) | ||
} | ||
} |
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