Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add box-drawing character to the snapshots command #728

Merged
merged 1 commit into from Jan 29, 2017

Conversation

cit
Copy link
Contributor

@cit cit commented Jan 18, 2017

The following pull request adds box-drawing characters to the output of the snapshot command to visualize which directory belongs to which snapshot. It looks like the following:

   ID           Date                 Host        Tags        Directory
----------------------------------------------------------------------
├──97d80712     2017-01-17 12:47:26  voyager                 /home/cit/Videos
├──6def47be     2017-01-17 14:03:07  voyager                 /home/cit/Dokumente
│  └──                                                       /home/cit/Videos
├──2a74e4fa     2017-01-17 14:12:37  voyager                 /home/cit/Backup
│  ├──                                                       /home/cit/Dokumente
│  └──                                                       /home/cit/Videos
├──f02dd44d     2017-01-17 20:37:23  voyager                 /home/cit/Backup
│  ├──                                                       /home/cit/Dokumente
│  ├──                                                       /home/cit/Sync
│  └──                                                       /home/cit/Videos

@@ -115,7 +115,12 @@ func runSnapshots(opts SnapshotOptions, gopts GlobalOptions, args []string) erro
tag = sn.Tags[i]
}

tab.Rows = append(tab.Rows, []interface{}{"", "", "", tag, path})
tree_element := "│ ├──"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't use underscores in Go names; var tree_element should be treeElement

@codecov-io
Copy link

codecov-io commented Jan 19, 2017

Current coverage is 54.17% (diff: 0.00%)

Merging #728 into master will decrease coverage by 0.11%

@@             master       #728   diff @@
==========================================
  Files            95         95          
  Lines          7263       7269     +6   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
- Hits           3943       3938     -5   
- Misses         2742       2754    +12   
+ Partials        578        577     -1   

Powered by Codecov. Last update d55b56e...54c2f62

@fd0
Copy link
Member

fd0 commented Jan 19, 2017

Thanks for your contribution!

I have two questions:

  • Does this work on Windows, with the Unicode characters?
  • I feel that the way it is drawn right now does not improve the visualisation when there are more than ~5 directories:
   ID           Date                 Host        Tags        Directory
----------------------------------------------------------------------
├──97d80712     2017-01-17 12:47:26  voyager                 /home/cit/Videos
├──6def47be     2017-01-17 14:03:07  voyager                 /home/cit/Dokumente
│  ├──                                                       /home/cit/Sync
│  ├──                                                       /home/cit/Sync
│  ├──                                                       /home/cit/Sync
│  ├──                                                       /home/cit/Sync
│  ├──                                                       /home/cit/Sync
│  ├──                                                       /home/cit/Sync
│  └──                                                       /home/cit/Videos
├──2a74e4fa     2017-01-17 14:12:37  voyager                 /home/cit/Backup
│  ├──                                                       /home/cit/Dokumente
│  ├──                                                       /home/cit/Sync
│  ├──                                                       /home/cit/Sync
│  ├──                                                       /home/cit/Sync
│  ├──                                                       /home/cit/Sync
│  ├──                                                       /home/cit/Sync
│  ├──                                                       /home/cit/Sync
│  ├──                                                       /home/cit/Sync
│  └──                                                       /home/cit/Videos
├──f02dd44d     2017-01-17 20:37:23  voyager                 /home/cit/Backup
│  ├──                                                       /home/cit/Dokumente
│  ├──                                                       /home/cit/Sync
│  ├──                                                       /home/cit/Sync
│  ├──                                                       /home/cit/Sync
│  ├──                                                       /home/cit/Sync
│  ├──                                                       /home/cit/Sync
│  ├──                                                       /home/cit/Sync
│  ├──                                                       /home/cit/Sync
│  ├──                                                       /home/cit/Sync
│  ├──                                                       /home/cit/Sync
│  └──                                                       /home/cit/Videos

I'd prefer to draw the tree where the directories are listed, in the right-most column, what do you think?

@cit
Copy link
Contributor Author

cit commented Jan 19, 2017

Does this work on Windows, with the Unicode characters?

I have tested it with Windows 7 and powershell and it seems to work:

restic-windows-snapshots

However, if the a terminal/shell does not support unicode, I think the output will look strange. I think to solve this problem is to check if the shell supports unicode and if not change the output to an ASCII representation (similar to tree --charset=ascii). I'm not sure if this is so easy.

I feel that the way it is drawn right now does not improve the visualisation when there are more than ~5 directories: I'd prefer to draw the tree where the directories are listed, in the right-most column, what do you think?

The actual problem that I had with the previous snapshots output was that I thought a line without an ID is a corrupted snapshot. At first sight it was not clear to me that a line without an ID belongs to the previous line with an ID. That is why I put the tree in the left-most column to the ID. However, I can give it a try and post an example here to see if this increases the visualisation:

    ID           Date                 Host        Tags        Directory
----------------------------------------------------------------------
97d80712        2017-01-17 12:47:26  voyager                 ───/home/cit/Videos
6def47be        2017-01-17 14:03:07  voyager                 ┌──/home/cit/Dokumente
                                                             └──/home/cit/Videos
2a74e4fa        2017-01-17 14:12:37  voyager                 ┌──/home/cit/Backup
                                                             ├──/home/cit/Dokumente
                                                             └──/home/cit/Videos
f02dd44d        2017-01-17 20:37:23  voyager                 ┌──/home/cit/Backup
                                                             ├──/home/cit/Dokumente
                                                             ├──/home/cit/Sync
                                                             └──/home/cit/Videos
 

Do you think this improves the visualisation?

@fd0
Copy link
Member

fd0 commented Jan 20, 2017

Thanks for the example. I think that this indeed looks better when the tree is drawn in the rightmost column.

If it works on Windows 7 I think that's sufficient, let's see if we get any reports from people with non-utf-8 terminals.

I'm currently thinking if there's a better way to solve your original problem in a better way. I've thought about inserting a line (---- etc) between the lines, but that's not considered good design and clutters the snapshot display a lot. Maybe alternating row colors? This will get lost on monochrome terminals, though. What do you think?

@fd0 fd0 added the state: need feedback waiting for feedback, e.g. from the submitter label Jan 23, 2017
@cit
Copy link
Contributor Author

cit commented Jan 23, 2017

I agree with you: both colors and dashed lines are suboptimal. Maybe it makes sense to change the display altogether. During my research, I found an interesting display which could be adapted for snapshots:

display

What do you think about this?

@fd0
Copy link
Member

fd0 commented Jan 23, 2017

What do you think about this:

    ID           Date                 Host        Tags        Directory
----------------------------------------------------------------------
97d80712        2017-01-17 12:47:26  voyager                   /home/cit/Videos
6def47be        2017-01-17 14:03:07  voyager                ┌─ /home/cit/Dokumente
                                                            └─ /home/cit/Videos
2a74e4fa        2017-01-17 14:12:37  voyager                ┌─ /home/cit/Backup
                                                            │  /home/cit/Dokumente
                                                            └─ /home/cit/Videos
f02dd44d        2017-01-17 20:37:23  voyager                ┌─ /home/cit/Backup
                                                            │  /home/cit/Dokumente
                                                            │  /home/cit/Sync
                                                            └─ /home/cit/Videos

@fd0
Copy link
Member

fd0 commented Jan 23, 2017

I can't really imagine what snapshots look like in that theme... I'm not clinging to the current snapshot list, so if you have something better I'm open to changing it. So we'll close this PR for now?

@fd0
Copy link
Member

fd0 commented Jan 23, 2017

By the way: What's the software in the screenshot?

@cit
Copy link
Contributor Author

cit commented Jan 23, 2017

Sure this presentation solves the problem for me. It was https://github.com/liangxianzhe/oh-my-vim

@fd0 fd0 removed the state: need feedback waiting for feedback, e.g. from the submitter label Jan 26, 2017
Copy link
Member

@fd0 fd0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks a lot for your work!

@fd0
Copy link
Member

fd0 commented Jan 26, 2017

Could you please squash your commits (using git rebase -i master, then do git push -f)? I'll then merge this PR. Thanks!

Remove underscore of variable name

Format code with gofmt

Change snapshot output according to the discussion
@fd0 fd0 merged commit 54c2f62 into restic:master Jan 29, 2017
fd0 added a commit that referenced this pull request Jan 29, 2017
Add box-drawing character to the snapshots command
@fd0
Copy link
Member

fd0 commented Jan 29, 2017

Merged, thanks a lot for your contribution!

@cit cit deleted the improve-snapshot-output branch January 29, 2017 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants