Added latest keyword in ls command.
This commit is contained in:
parent
f9501e97a2
commit
02c02283cf
1 changed files with 16 additions and 3 deletions
|
@ -17,6 +17,8 @@ var cmdLs = &cobra.Command{
|
||||||
Short: "list files in a snapshot",
|
Short: "list files in a snapshot",
|
||||||
Long: `
|
Long: `
|
||||||
The "ls" command allows listing files and directories in a snapshot.
|
The "ls" command allows listing files and directories in a snapshot.
|
||||||
|
|
||||||
|
The special snapshot-ID "latest" can be used to list files and directories of the latest snapshot in the repository.
|
||||||
`,
|
`,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
return runLs(globalOptions, args)
|
return runLs(globalOptions, args)
|
||||||
|
@ -86,10 +88,21 @@ func runLs(gopts GlobalOptions, args []string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
id, err := restic.FindSnapshot(repo, args[0])
|
snapshotIDString := args[0]
|
||||||
|
var id restic.ID
|
||||||
|
var paths []string
|
||||||
|
|
||||||
|
if snapshotIDString == "latest" {
|
||||||
|
id, err = restic.FindLatestSnapshot(repo, paths, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
id, err = restic.FindSnapshot(repo, snapshotIDString)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sn, err := restic.LoadSnapshot(repo, id)
|
sn, err := restic.LoadSnapshot(repo, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue