Support selecting host to use when creating a gist
Support selecting host to use when creating a gist
When logged into github.com and an enterprise version of Github, when I go to create a gist, it defaults to creating the gist on github.com. There is no simple way to specify which host to use when creating a gist.
Proposed solution
I suggest adding a --host and -h parameter which would allow one to specify which host to use when creating the gist. This will make it easy to select a host on a command by command basis. The host specified should match one listed in$HOME/.config/gh/hosts.yml.
Additional context
For Linux users, the workaround today is to temporarily set the GH_HOST variable before running the command, like this:
GH_HOST=github.my-company.com gist create ...
If this feature is not implemented then I suggest the documentation should be updated to document the workaround above.
@cvoltz Right now GH_HOST is the only way we support overriding the selected host for most commands, some commands that take a repo arguments allow specifying the host as part of the repo URL but obviously that is not possible with gists as they do not belong to a repo. We do have GH_HOST documented in gh help environment, I am curious what other documentation do you think is necessary to make this more discoverable?
When using the help from the gist command it wasn't obvious and I didn't think to run gh help environment to find the setting. Looking at the online manual, I guess it is sufficiently documented that you can set the setting to apply for all operations. My only suggestion perhaps would be to add a note about being able to switch between repos by setting GH_HOST for only that command, as I showed above. In my case, I created the shell alias ghe to run gh with GH_HOST set appropriately for the enterprise instance so I can just run gh for github.com and ghe for the enterprise instance. That makes it pretty convenient to switch back and forth.
Working in a large enterprise, we have 3 github enterprise installations, and I also use github.com. Having a flag to target the specific instance or support using the url that includes the server is highly desirable. Consistency between all the commands would also help. Specifically, I was trying to do a repo list on a specific host & organization and found that the env var is the only current option.
We do have GH_HOST documented in gh help environment, I am curious what other documentation do you think is necessary to make this more discoverable?
It never occurred to me to look at another help topic when I was running gh repo list --help. Fortunately, I stumbled upon this question rather quickly in my search.
If a --host flag is unlikely to come in the near future, maybe the Learn More section of commands should include a sentence along the lines of "For more customization options use gh help environment to learn about environment variables you can set.