Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1302)

Unified Diff: worker/apiuniter/jujuc/config-get.go

Issue 13401050: worker;cmd/jujud: Replace uniter with apiuniter (Closed)
Patch Set: worker;cmd/jujud: Replace uniter with apiuniter Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « worker/apiuniter/hook/hook_test.go ('k') | worker/apiuniter/jujuc/config-get_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: worker/apiuniter/jujuc/config-get.go
=== removed file 'worker/apiuniter/jujuc/config-get.go'
--- worker/apiuniter/jujuc/config-get.go 2013-09-10 12:21:02 +0000
+++ worker/apiuniter/jujuc/config-get.go 1970-01-01 00:00:00 +0000
@@ -1,77 +0,0 @@
-// Copyright 2012, 2013 Canonical Ltd.
-// Licensed under the AGPLv3, see LICENCE file for details.
-
-package jujuc
-
-import (
- "fmt"
-
- "launchpad.net/gnuflag"
- "launchpad.net/juju-core/cmd"
-)
-
-// ConfigGetCommand implements the config-get command.
-type ConfigGetCommand struct {
- cmd.CommandBase
- ctx Context
- Key string // The key to show. If empty, show all.
- All bool
- out cmd.Output
-}
-
-func NewConfigGetCommand(ctx Context) cmd.Command {
- return &ConfigGetCommand{ctx: ctx}
-}
-
-func (c *ConfigGetCommand) Info() *cmd.Info {
- doc := `
-When no <key> is supplied, all keys with values or defaults are printed. If
---all is set, all known keys are printed; those without defaults or values are
-reported as null. <key> and --all are mutually exclusive.
-`
- return &cmd.Info{
- Name: "config-get",
- Args: "[<key>]",
- Purpose: "print service configuration",
- Doc: doc,
- }
-}
-
-func (c *ConfigGetCommand) SetFlags(f *gnuflag.FlagSet) {
- c.out.AddFlags(f, "smart", cmd.DefaultFormatters)
- f.BoolVar(&c.All, "a", false, "print all keys")
- f.BoolVar(&c.All, "all", false, "")
-}
-
-func (c *ConfigGetCommand) Init(args []string) error {
- if args == nil {
- return nil
- }
- c.Key = args[0]
- if c.Key != "" && c.All {
- return fmt.Errorf("cannot use argument --all together with key %q", c.Key)
- }
-
- return cmd.CheckEmpty(args[1:])
-}
-
-func (c *ConfigGetCommand) Run(ctx *cmd.Context) error {
- settings, err := c.ctx.ConfigSettings()
- if err != nil {
- return err
- }
- var value interface{}
- if c.Key == "" {
- if !c.All {
- for k, v := range settings {
- if v == nil {
- delete(settings, k)
- }
- }
- }
- value = settings
- } else {
- value, _ = settings[c.Key]
- }
- return c.out.Write(ctx, value)
-}
« no previous file with comments | « worker/apiuniter/hook/hook_test.go ('k') | worker/apiuniter/jujuc/config-get_test.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b