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

Make homeshick output machine readable #70

Open
andsens opened this issue Dec 12, 2013 · 5 comments
Open

Make homeshick output machine readable #70

andsens opened this issue Dec 12, 2013 · 5 comments

Comments

@andsens
Copy link
Owner

andsens commented Dec 12, 2013

Currently homeshick outputs text that is very readable by a human when viewed through a terminal. However, when read by or though anything else it becomes quite a challenge because carriage returns (\r) and coloring have to be taken into account.

homeshick should check whether STDOUT is the terminal and only then output data optimized for human viewing. This can easily be checked with [ -t 1].
This enhancement also makes unittests easier and allows for homeshick to be integrated with other code.

@ghost ghost assigned andsens Dec 12, 2013
@andsens andsens removed their assignment Aug 30, 2014
@dougborg
Copy link
Contributor

I like this idea - I have noticed the output gets a bit mangled in the bats unit tests as well. So, you just want a raw stream of files + action taken by homeshick streamed to stdout if ! [[ -t 1 ]]? I could see something like a list with two columns:

identical .bash_profile
identical .bashrc
identical .bashrc.d
identical .bashrc.d/functions
identical .bashrc.d/functions/completion.sh
identical .bashrc.d/functions/gcd.sh
identical .bashrc.d/functions/path-manip.sh
identical .bashrc.d/functions/smart-alias.sh
identical .bashrc.d/functions/ssh-login.sh
identical .bashrc.d/functions/update.sh
identical .bashrc.d/platform
identical .bashrc.d/platform/cygwin.sh
identical .bashrc.d/platform/darwin.sh
identical .bashrc.d/platform/linux.sh
identical .bashrc.d/topics
identical .bashrc.d/topics/aliases.sh
identical .bashrc.d/topics/bash.sh
identical .bashrc.d/topics/brew.sh
identical .bashrc.d/topics/colors.sh
identical .bashrc.d/topics/deploy.sh
identical .bashrc.d/topics/git.sh
identical .bashrc.d/topics/go.sh
identical .bashrc.d/topics/homeshick.sh
identical .bashrc.d/topics/node.sh
identical .bashrc.d/topics/prompt.sh
identical .bashrc.d/topics/ruby.sh
identical .bashrc.d/topics/ssh.sh
...

Does it make sense to change the separator between action and the file? Maybe we could use a comma or a tab instead of a space so you can cut with that delimiter and still be ok if your filenames have spaces, etc.

@andsens
Copy link
Owner Author

andsens commented Oct 14, 2014

Agreed to everything. I'd go for the tab. Or instead maybe just remove the spaces in the left column?

@dougborg
Copy link
Contributor

I am not sure how removing spaces in the left column would work. How would the program interpreting the output know where to put them back so they could do something useful with the filename?

@andsens
Copy link
Owner Author

andsens commented Oct 14, 2014

You'd just separate by the first space, so up to date becomes uptodate. Then you can use cut -d' ' -f2- to get the filename and cut -d' ' -f1 to get the action. Then again, <tab> is the standard for cut, so it might really just be easier to use that.

@dougborg
Copy link
Contributor

Oh of course! I thought by 'left" column you meant the "right" column with the file name 😞. All things considered, I agree using <tab> is probably the best solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants