Shards: Argument to version command - path or dependency name?

Created on 6 Sep 2018  路  6Comments  路  Source: crystal-lang/shards

148 introduced shards version command which prints the version specified in shard.yml. The command accepts an optional parameter path which can be used to specifiy to look for shard.yml in a different path.

@luislavena Was there a specific reason for this feature?

To me, it feels a little bit strange. I mean, it being able to specify a different directory is nice, but wouldn't that make sense for all commands? Similar to make -C path. I think it is better to use a named option. It is not intuitive that the first argument to version is interpreted as a path to look for a shard.yml.

I'd rather suggest shards version to have an argument to specify a dependency name and it would print the installed version of that dependency.
For example, inside shards directory, shards version minitest would print 0.3.5.

enhancement help wanted

Most helpful comment

I suppose we could have shards version [-c <path>] [<dependency>]. It's a breaking change, but the command would feel a little more complete.

All 6 comments

Hello @straight-shoota, the reasoning for the second argument is explained in the pull request, which is a response to the RFC #147.

See https://github.com/crystal-lang/shards/issues/147#issuecomment-276090449 for the specific use case.

Ah, somehow I missed that. Thanks for pointing it out.

The example in the linked comment should also work with shards version -C __DIR__, for example. Or maybe just shards version wonderful which would resolve the location of the shard (wonderful in this example). In this use case, specifying the shard name has a little bit overhead because it resolves the location again which is already available in __DIR__. But considering that it needs to traverse the parent directory, this doesn't really matter.

I suppose we could have shards version [-c <path>] [<dependency>]. It's a breaking change, but the command would feel a little more complete.

For backwards compatibility, it could even treat <dependecy> as a path if no dependency with that name is specified (and the path exists, obviously).

Since there has been no PR for this issue so far, I will remove it from the milestone v0.10.0

I would suggest to close this issue in favour of a more general approach to querying information (including the version) of installed shards (see https://github.com/crystal-lang/shards/issues/86#issuecomment-588208805).

Was this page helpful?
0 / 5 - 0 ratings