Skip to content
This repository was archived by the owner on Feb 16, 2023. It is now read-only.

Commit 0fcd566

Browse files
committed
Add env read command (doesn't do anything yet)
1 parent 46ad1c2 commit 0fcd566

3 files changed

Lines changed: 59 additions & 0 deletions

File tree

internals/secrethub/app.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ func (app *App) registerCommands() {
163163
NewAccountCommand(app.io, app.clientFactory.NewClient, app.credentialStore).Register(app.cli)
164164
NewCredentialCommand(app.io, app.clientFactory, app.credentialStore).Register(app.cli)
165165
NewConfigCommand(app.io, app.credentialStore).Register(app.cli)
166+
NewEnvCommand(app.io, app.clientFactory.NewClient).Register(app.cli)
166167

167168
// Commands
168169
NewInitCommand(app.io, app.clientFactory.NewUnauthenticatedClient, app.clientFactory.NewClientWithCredentials, app.credentialStore).Register(app.cli)

internals/secrethub/env.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package secrethub
2+
3+
import (
4+
"github.com/secrethub/secrethub-cli/internals/cli/ui"
5+
"github.com/secrethub/secrethub-cli/internals/secrethub/command"
6+
)
7+
8+
// EnvCommand handles operations regarding environment variables.
9+
type EnvCommand struct {
10+
io ui.IO
11+
newClient newClientFunc
12+
}
13+
14+
// NewEnvCommand creates a new EnvCommand.
15+
func NewEnvCommand(io ui.IO, newClient newClientFunc) *EnvCommand {
16+
return &EnvCommand{
17+
io: io,
18+
newClient: newClient,
19+
}
20+
}
21+
22+
// Register registers the command and its sub-commands on the provided Registerer.
23+
func (cmd *EnvCommand) Register(r command.Registerer) {
24+
clause := r.Command("env", "Manage environment variables.").Hidden() // The command is hidden, because it's still in beta.
25+
NewEnvReadCommand(cmd.io, cmd.newClient).Register(clause)
26+
}

internals/secrethub/env_read.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package secrethub
2+
3+
import (
4+
"github.com/secrethub/secrethub-cli/internals/cli/ui"
5+
"github.com/secrethub/secrethub-cli/internals/secrethub/command"
6+
)
7+
8+
// EnvReadCommand is a command to read the value of a single environment variable.
9+
type EnvReadCommand struct {
10+
io ui.IO
11+
newClient newClientFunc
12+
}
13+
14+
// NewEnvReadCommand creates a new EnvReadCommand.
15+
func NewEnvReadCommand(io ui.IO, newClient newClientFunc) *EnvReadCommand {
16+
return &EnvReadCommand{
17+
io: io,
18+
newClient: newClient,
19+
}
20+
}
21+
22+
// Register adds a CommandClause and it's args and flags to a Registerer.
23+
func (cmd *EnvReadCommand) Register(r command.Registerer) {
24+
clause := r.Command("read", "Read the value of a single environment variable.")
25+
26+
command.BindAction(clause, cmd.Run)
27+
}
28+
29+
// Run handles the command with the options as specified in the command.
30+
func (cmd *EnvReadCommand) Run() error {
31+
return nil
32+
}

0 commit comments

Comments
 (0)