-
-
Notifications
You must be signed in to change notification settings - Fork 100
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
Introduces version
command to retrieve shards current version
#148
Conversation
src/commands/version.cr
Outdated
end | ||
|
||
def run(*args) | ||
puts spec.version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use print
so that chomp doesn't have to be used in the macro?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess because you'll get borked output using cli.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh... My prompt seems to fix that for me. Never mind then.
version
to retrieve shards current versionversion
command to retrieve shards current version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall. Just a few tiny details, and are you testing that the command will search up the directory tree until if finds a spec file?
src/commands/version.cr
Outdated
module Commands | ||
class Version < Command | ||
def self.run(path, *args) | ||
# look up for `shard.yml` in given directory or up |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe extract this part as a method? For example lookup_spec(path) : String?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was thinking on that, but that would be a another class method, so perhaps is better move that to a helper instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, private class method is fine. There is no other usage of it for now.
src/commands/version.cr
Outdated
break if File.exists?(shard_file) | ||
|
||
previous = current | ||
current = File.expand_path("..", current) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about leveraging File.dirname
?
Yes, see Will get those changes done soon. Thank you. |
Sometimes is useful to obtain the current version string of the library/project you're working on, either to help you determine if was bumped (when preparing for a new release) or when integrating it within the library's `VERSION` constant (through macros). This change introduces `version` command for such purpose, allowing you retrieve from current directory (by default) or be able to provide a different path. Usage example module Foo VERSION = {{ `shards version #{__DIR__}`.chomp.stringify }} end Resulting in a `Foo::VERSION` matching the `version` defined in `shard.yml`. Fixes #147
@ysbaddaden changes pushed, waiting for Travis OSX to confirm. Cheers. |
Thank you! |
Introduces `version` command to retrieve shards current version
Sometimes is useful to obtain the current version string of the library/project you're working on, either to help you determine if was bumped (when preparing for a new release) or when integrating it within the library's
VERSION
constant (through macros).This change introduces
version
command for such purpose, allowing you retrieve from current directory (by default) or be able to provide a different path.Usage example
Resulting in a
Foo::VERSION
matching theversion
defined inshard.yml
.Fixes #147