From 881a8a1366002fb8692e5bf938260e6213d32d75 Mon Sep 17 00:00:00 2001 From: "Anand Babu (AB) Periasamy" Date: Thu, 12 Nov 2015 00:11:55 -0800 Subject: [PATCH] cat code review --- cat-main.go | 20 +++++--------------- ls-main.go | 15 ++++++++------- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/cat-main.go b/cat-main.go index 17e16de2..db421716 100644 --- a/cat-main.go +++ b/cat-main.go @@ -42,24 +42,18 @@ USAGE: mc {{.Name}} SOURCE [SOURCE...] EXAMPLES: - 1. Concantenate an object from Amazon S3 cloud storage to mplayer standard input. + 1. Stream an object from Amazon S3 cloud storage to mplayer standard input. $ mc {{.Name}} https://s3.amazonaws.com/ferenginar/klingon_opera_aktuh_maylotah.ogg | mplayer - 2. Concantenate contents of file1.txt and stdin to standard output. $ mc {{.Name}} file1.txt - > file.txt - 3. Concantenate multiple files from the local filesystem to standard output. + 3. Concantenate multiple files to one. $ mc {{.Name}} part.* > complete.img - 4. Concatenate a non english file name from Amazon S3 cloud storage. - $ mc {{.Name}} s3/andoria/本語 > /tmp/本語 - - 5. Behave like operating system ‘cat’ tool. Useful for alias cat='mc --mimic cat'. - $ echo "Hello, World!" | mc --mimic {{.Name}} - Hello, World! - - 6. Concantenate an object with space characters from Amazon S3 cloud storage. - $ mc {{.Name}} 's3/miniocloud/Readme First.txt' | head -1 + 4. Behave like operating system ‘cat’ tool. Useful for aliasing. + $ alias {{.Name}}='mc --mimic {{.Name}}' + $ {{.Name}} /etc/issue.txt `, } @@ -101,10 +95,6 @@ func catURL(sourceURL string) *probe.Error { // catOut reads from reader stream and writes to stdout. func catOut(r io.Reader) *probe.Error { - // Do not forget to flush after stdout. - // out := bufio.NewWriter(os.Stdout) - // defer out.Flush() - // Read till EOF. if _, err := io.Copy(os.Stdout, r); err != nil { switch e := err.(type) { diff --git a/ls-main.go b/ls-main.go index 3ed6758e..0467f5dc 100644 --- a/ls-main.go +++ b/ls-main.go @@ -66,20 +66,21 @@ EXAMPLES: ... 4. List files with non-English characters on Amazon S3 cloud storage. - $ mc ls s3/andoria/本... + $ mc {{.Name}} s3/andoria/本... [2015-05-19 17:28:22 PDT] 41B 本語.md 5. List folders with space separated names on Amazon S3 cloud storage. - $ mc ls 's3/miniocloud/Community Files/' + $ mc {{.Name}} 's3/miniocloud/Community Files/' [2015-05-19 17:28:22 PDT] 41B 本語.md - 6. Behave like an operating system ‘ls’. [HINT: Add it to your shell alias]. - $ mc --mimic ls + 6. Behave like operating system ‘ls’ tool. Useful for aliasing. + $ alias ls='mc --mimic ls' + $ {{.Name}} [2015-05-19 17:28:22 PDT] 41B 本語.md - 7. List incomplete uploads of objects on Amazon S3. - $ mc ls --incomplete s3/mybucket - [2015-10-19 22:28:02 PDT] 32MiB backup/server112-11Nov15.tgz + 7. List incomplete (previously failed) uploads of objects on Amazon S3. + $ mc {{.Name}} --incomplete s3/mybucket + [2015-10-19 22:28:02 PDT] 41MiB backup/server112-11Nov15.tgz `, }