git2json icon indicating copy to clipboard operation
git2json copied to clipboard

[Feature request] Option to pass custom git location

Open CoenraadS opened this issue 7 years ago • 3 comments

Hi

Sometimes the user does not have git in the path, so I would like to pass custom path to git executable.

CoenraadS avatar Apr 29 '18 18:04 CoenraadS

@CoenraadS, just wanted to clarify, but you are wanting to be able to specify the path for cli usage, yeah? #2 added support for specifying a path(s) when using git2json as a library. Adding the functionality for cli usage completely slipped my mind.

@fabien0102 (@CoenraadS your input would also be great) I have a PR ready with this functionality, but having trouble deciding on two different implementations. Just need your opinion and I can finish it up and submit it.

Which of the following two ways should the cli function?

OPTION 1: paths specified as base arguments

Any arguments after the initial command are interpreted as target paths. The help print out would show something along these lines for 'Usage:'

Usage: git2json [options] [<path>...]

Options:
-h, --help
-v, --version

Here are some examples of actual usage with this implementation.

Single path argument:

git2json /Users/fielding/src/hack/git2json

Multiple path arguments:

git2json /Users/fielding/src/hack/git2json /Users/fielding/src

and of course the naked command is still valid if the current directory is the target git repository

git2json

OPTION 2: paths specifed as options

The -p or --path flag can be used optionally to specify a different target directory. The help print out would show something along these lines for 'Usage:'

Usage: git2json [options]

Options:
-h, --help
-p, --path <PATH>
-v, --version

Here are some examples of actual usage with this implementation.

Single path argument:

git2json -p /Users/fielding/src/hack/git2json
git2json --path /Users/fielding/src/hack/git2json

Multiple path arguments with their own -p or --path flag or following one -p or --path flag

git2json -p /Users/fielding/src/hack/git2json /Users/fielding/src
git2json -p /Users/fielding/src/hack/git2json -p /Users/fielding/src

and of course the naked command is still valid if the current directory is the target git repository

git2json

And of course if there is a desired implementation other than these two then let me know and I will make it happen. I see the pros and cons to each implementation and overall I am indifferent to which is used, so let me know and I will get the PR submitted right away.

Happy hacking, Fielding

fielding avatar Oct 02 '18 18:10 fielding

I think I prefer the option 1 👍

fabien0102 avatar Oct 04 '18 11:10 fabien0102

Excellent. I have completed that implementation and will submit the PR once #11 is merged. Since #11 seemed to be well received, I cheated and based the PR for this off of #11 to simplify a few issues.

fielding avatar Oct 05 '18 13:10 fielding