Merge branch 'add_config_show_command' of https://github.com/queeno/aptly into queeno-add_config_show_command-2

This commit is contained in:
Andrey Smirnov
2014-10-14 18:17:21 +04:00
4 changed files with 61 additions and 2 deletions
+4 -2
View File
@@ -3,12 +3,13 @@ package cmd
import (
"fmt"
"os"
"time"
"github.com/smira/aptly/aptly"
"github.com/smira/aptly/deb"
"github.com/smira/commander"
"github.com/smira/flag"
"os"
"time"
)
// ListPackagesRefList shows list of packages in PackageRefList
@@ -65,6 +66,7 @@ fine-grained changes in repository contents to transition your
package environment to new version.`,
Flag: *flag.NewFlagSet("aptly", flag.ExitOnError),
Subcommands: []*commander.Command{
makeCmdConfig(),
makeCmdDb(),
makeCmdGraph(),
makeCmdMirror(),
+15
View File
@@ -0,0 +1,15 @@
package cmd
import (
"github.com/smira/commander"
)
func makeCmdConfig() *commander.Command {
return &commander.Command{
UsageLine: "config",
Short: "manage aptly configuration",
Subcommands: []*commander.Command{
makeCmdConfigShow(),
},
}
}
+41
View File
@@ -0,0 +1,41 @@
package cmd
import (
"encoding/json"
"fmt"
"github.com/smira/commander"
)
func aptlyConfigShow(cmd *commander.Command, args []string) error {
config := context.Config()
pretty_json, err := json.MarshalIndent(config, "", " ")
if err != nil {
return fmt.Errorf("unable to parse the config file: %s", err)
}
config_to_string := string(pretty_json)
fmt.Println(config_to_string)
return nil
}
func makeCmdConfigShow() *commander.Command {
cmd := &commander.Command{
Run: aptlyConfigShow,
UsageLine: "show",
Short: "show current aptly's config",
Long: `
Command show displays the current aptly configuration.
Example:
$ aptly config show
`,
}
return cmd
}
+1
View File
@@ -3,6 +3,7 @@ aptly - Debian repository management tool
Commands:
api start API server/issue requests
config manage aptly configuration
db manage aptly's internal database and package pool
graph render graph of relationships
mirror manage mirrors of remote repositories