Add -raw for aptly publish list. #31

This commit is contained in:
Andrey Smirnov
2014-04-15 23:53:53 +04:00
parent 8d214e6d12
commit e33f5792e1
3 changed files with 43 additions and 8 deletions

View File

@@ -14,10 +14,7 @@ func aptlyPublishList(cmd *commander.Command, args []string) error {
return err
}
if context.CollectionFactory().PublishedRepoCollection().Len() == 0 {
fmt.Printf("No snapshots have been published. Publish a snapshot by running `aptly publish snapshot ...`.\n")
return err
}
raw := cmd.Flag.Lookup("raw").Value.Get().(bool)
published := make([]string, 0, context.CollectionFactory().PublishedRepoCollection().Len())
@@ -27,7 +24,11 @@ func aptlyPublishList(cmd *commander.Command, args []string) error {
return err
}
published = append(published, repo.String())
if raw {
published = append(published, fmt.Sprintf("%s %s", repo.Prefix, repo.Distribution))
} else {
published = append(published, repo.String())
}
return nil
})
@@ -37,10 +38,21 @@ func aptlyPublishList(cmd *commander.Command, args []string) error {
sort.Strings(published)
fmt.Printf("Published repositories:\n")
if raw {
for _, info := range published {
fmt.Printf("%s\n", info)
}
} else {
if len(published) == 0 {
fmt.Printf("No snapshots/local repos have been published. Publish a snapshot by running `aptly publish snapshot ...`.\n")
return err
}
for _, description := range published {
fmt.Printf(" * %s\n", description)
fmt.Printf("Published repositories:\n")
for _, description := range published {
fmt.Printf(" * %s\n", description)
}
}
return err
@@ -60,5 +72,7 @@ Example:
`,
}
cmd.Flag.Bool("raw", false, "display list in machine-readable format")
return cmd
}

View File

@@ -0,0 +1,4 @@
. maverick
ppa/smira wheezy
ppa/tr1 maverick
ppa/tr2 maverick

View File

@@ -23,3 +23,20 @@ class PublishList2Test(BaseTest):
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -label=label1 snap2 ppa/tr2",
]
runCmd = "aptly publish list"
class PublishList3Test(BaseTest):
"""
publish list: several repos list, raw
"""
fixtureDB = True
fixturePool = True
fixtureCmds = [
"aptly snapshot create snap1 from mirror gnuplot-maverick",
"aptly snapshot merge snap2 snap1",
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec snap1",
"aptly -architectures=amd64 publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=wheezy -component=contrib snap2 ppa/smira",
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -origin=origin1 snap2 ppa/tr1",
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -label=label1 snap2 ppa/tr2",
]
runCmd = "aptly publish list -raw"