Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: garden community command #4129

Merged
merged 2 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions core/src/commands/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import { Command, CommandGroup } from "./base"
import { BuildCommand } from "./build"
import { CommunityCommand } from "./community"
import { CreateCommand } from "./create/create"
import { DeleteCommand } from "./delete"
import { DeployCommand } from "./deploy"
Expand Down Expand Up @@ -41,6 +42,7 @@ import { SyncCommand } from "./sync/sync"
export const getCoreCommands = (): (Command | CommandGroup)[] => [
new BuildCommand(),
new ConfigCommand(),
new CommunityCommand(),
new CreateCommand(),
new DeleteCommand(),
new DeployCommand(),
Expand Down
38 changes: 38 additions & 0 deletions core/src/commands/community.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (C) 2018-2023 Garden Technologies, Inc. <[email protected]>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

import { Command, CommandResult } from "./base"
import dedent = require("dedent")
import { exec } from "../util/util"

export class CommunityCommand extends Command {
name = "community"
help = "Join our community Discord to chat with us!"

description = dedent`
Opens the Garden Community Discord invite link
`

loggerType: "basic"

noProject = true

printHeader() {}

async action(): Promise<CommandResult> {
const discordInvite = "https://discord.gg/FrmhuUjFs6"
// eslint-disable-next-line no-console
console.log(discordInvite)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A colored message might be a better option here. Something like "Welcome to our community! Join us on Discord: {link}".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My initial thought was to keep it simple and only output the link in order to make it easier to copy/paste for folks who are not using a terminal emulator that supports clickable link detection. The command is also calling an open handler, so the printed line is more of a backup method anyway, and leaves a trail of history for what was opened.

But I have no strong opinions here - we can also tweak this further if we want to, easy changes to make ❤️


try {
await exec("open", [discordInvite])
} catch (_) {}

return { result: { discordInvite } }
}
}