jamesob / desk

A lightweight workspace manager for the shell
MIT License
2.54k stars 111 forks source link

Fixes jamesob/desk#56 adding support for displaying exported environment variables in deskfiles #60

Closed cfont closed 8 years ago

cfont commented 8 years ago

I've added some working code to display the exported environment variables defined in a desk file as requested in jamesob/desk#56 by @rafaelbco. These code changes do compile and pass tests but that is probably because the tests haven't been increased to include whether this works or not ;-) but I guess the good thing is that it doesn't break anything else.

Please review and let me know if this is what you would like and I'll work on adding tests for this specific use case.

rafaelbco commented 8 years ago

Works as expected for me.

I suggest one improvement: add the $ character before the variable name in the output, like this:

$MYVAR  My environment variable.

Thanks a lot @cfont !

jamesob commented 8 years ago

Sweet! Nice work, @cfont!

Just want to be sure we package some tests with this. I'll write some a bit later unless you wanna take a crack at it yourself -- probably somewhere in here?

cfont commented 8 years ago

I want to take a crack at it myself and am planning to add it below the tests for hi and howdy which means I'll also need to modify that example hello deskfile to have one set. Between tonight and tomorrow, I plan on taking time to do some work on this.

cfont commented 8 years ago

Ok, so I've got a couple of new tests in here and an updated hello.sh deskfile for exported variables being displayed in the "What desk am I using currently" output. Everything is working and ready for your reviews and comments.

@rafaelbco, how important is it at this moment to have the $ character in front of the variable name? I ask because it isn't as "easy" as just adding it there since the code currently cycles through all of the "things" in the deskfile creating an array and then outputting them without regard to what kind of "thing" it might be. In other words, it currently doesn't discern whether it is an alias, function, or variable when rendering the output. If I go through and figure out which ones might be variables to prepend the $ character then I feel like it may be worth going ahead and separating them all by sections. Something like you originally used in your example:

mydesk - my desk to work on things.

  Aliases:
  howdy    Use if you're from Texas

  Functions:
  hi       Say in informal hello

  Environment variables:
  $MyName  James

My questions to everyone are:

rafaelbco commented 8 years ago

Well, for me the $ indicator is not that important. I think it's better to keep this PR simple.

Rafael Oliveira

On Wed, Mar 16, 2016 at 5:26 PM, Chris Fontenot notifications@github.com wrote:

Ok, so I've got a couple of new tests in here and an updated hello.sh deskfile for exported variables being displayed in the "What desk am I using currently" output. Everything is working and ready for your reviews and comments.

@rafaelbco https://github.com/rafaelbco, how important is it at this moment to have the $ character in front of the variable name? I ask because it isn't as "easy" as just adding it there since the code currently cycles through all of the "things" in the deskfile creating an array and then outputting them without regard to what kind of "thing" it might be. In other words, it currently doesn't discern whether it is an alias, function, or variable when rendering the output. If I go through and figure out which ones might be variables to prepend the $ character then I feel like it may be worth going ahead and separating them all by sections. Something like you originally used in your example:

mydesk - my desk to work on things.

Aliases: howdy Use if you're from Texas

Functions: hi Say in informal hello

Environment variables: $MyName James

My questions to everyone are:

  • do you want that indicator in this PR?
  • if so, do you also want some extra grouping?

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/jamesob/desk/pull/60#issuecomment-197532499

jamesob commented 8 years ago

@cfont @rafaelbco thanks, guys! Nice work with the tests, @cfont.