Added some comments

This commit is contained in:
Diptanu Choudhury 2016-01-26 16:37:26 -08:00
parent 2956f71519
commit 26d9554d02
3 changed files with 6 additions and 0 deletions

View File

@ -96,12 +96,14 @@ func (f *FSListCommand) Run(args []string) int {
} }
} }
// Ge the file at the given path
files, _, err := client.AllocFS().List(alloc, path, nil) files, _, err := client.AllocFS().List(alloc, path, nil)
if err != nil { if err != nil {
f.Ui.Error(fmt.Sprintf("Error listing alloc dir: %v", err)) f.Ui.Error(fmt.Sprintf("Error listing alloc dir: %v", err))
return 1 return 1
} }
// Display the file information in a tabular format
out := make([]string, len(files)+1) out := make([]string, len(files)+1)
out[0] = "Name|Size" out[0] = "Name|Size"
for i, file := range files { for i, file := range files {

View File

@ -97,6 +97,7 @@ func (f *FSCatCommand) Run(args []string) int {
} }
} }
// Stat the file to find it's size
file, _, err := client.AllocFS().Stat(alloc, path, nil) file, _, err := client.AllocFS().Stat(alloc, path, nil)
if err != nil { if err != nil {
f.Ui.Error(fmt.Sprintf("Error stating file: %v:", err)) f.Ui.Error(fmt.Sprintf("Error stating file: %v:", err))
@ -107,6 +108,7 @@ func (f *FSCatCommand) Run(args []string) int {
return 1 return 1
} }
// Get the contents of the file
offset := 0 offset := 0
limit := file.Size limit := file.Size
if _, err := client.AllocFS().ReadAt(alloc, path, int64(offset), limit, os.Stdout, nil); err != nil { if _, err := client.AllocFS().ReadAt(alloc, path, int64(offset), limit, os.Stdout, nil); err != nil {

View File

@ -96,12 +96,14 @@ func (f *FSStatCommand) Run(args []string) int {
} }
} }
// Get the file information
file, _, err := client.AllocFS().Stat(alloc, path, nil) file, _, err := client.AllocFS().Stat(alloc, path, nil)
if err != nil { if err != nil {
f.Ui.Error(fmt.Sprintf("Error stating file: %v:", err)) f.Ui.Error(fmt.Sprintf("Error stating file: %v:", err))
return 1 return 1
} }
// Display the file information
out := make([]string, 2) out := make([]string, 2)
out[0] = "Name|Size" out[0] = "Name|Size"
if file != nil { if file != nil {