Skip to content
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

Add a hugo build command as an alias for hugo #6417

Closed
jakejarvis opened this issue Oct 11, 2019 · 6 comments
Closed

Add a hugo build command as an alias for hugo #6417

jakejarvis opened this issue Oct 11, 2019 · 6 comments

Comments

@jakejarvis
Copy link
Contributor

Just a quick thought... It might be helpful to have a build command/alias such that hugo build == hugo.

For example, in a Dockerfile (like the current one) where the default command is --help, there doesn't seem to be an easy way to unset that to null and just run plain old hugo — the expected behavior is to be able to override the command to something like build at runtime (like we'd do for server or version). I'm sure there are some other (likely CI/automation related) cases where this might be helpful.

To be clear I consider this a limitation with Docker and not Hugo, but I've had this on my wishlist for a while now and I'm curious to hear any thoughts. Apologies for not having enough familiarity to make an actual PR, I poked around in commands/ for a bit and if others think this is a good idea I can spend some more time, I'm guessing it'd be fairly trivial. Feel free to close this if not, though! :)

@bep bep changed the title Proposal: Add a hugo build command as an alias for hugo Add a hugo build command as an alias for hugo Oct 11, 2019
@bep bep added this to the v0.59 milestone Oct 11, 2019
@bep
Copy link
Member

bep commented Oct 11, 2019

That sounds like an odd thing from Docker -- but it shouldn't cost us too much, and I can imagine other tools that also would like to have the symmetry of "hugo subcommand" for everything.

@BaibhaVatsa
Copy link
Contributor

Hi! I wished to work on this issue.

I was thinking that one way of solving this could be writing a function for the commandsBuilder type which returns a hugoCmd type. It would have the following in the RunE:

hugoCmd := b.newHugoCmd().getCommand()
return hugoCmd.RunE(cmd, args)

The new function could be placed in a new file named build.go in the commands directory.

Would love thoughts about this approach.

@klakegg
Copy link
Contributor

klakegg commented Oct 16, 2019

Given a configuration like this:

ENTRYPOINT ["hugo"]
CMD ["--help"]

I think it is possible to replace --help with "blank" by using the following in a new Dockerfile:

FROM .../hugo
CMD []

On the other side are there Docker images out there where command is not provided and build works as it should.

@bep
Copy link
Member

bep commented Oct 16, 2019

@BaibhaVatsa I was hoping that Cobra would handle this via its Aliases, but looking at it now you cannot refer to its parent. I need to think about this.

@bep bep modified the milestones: v0.59, v0.60 Oct 21, 2019
@bep bep modified the milestones: v0.60, v0.61, v0.62 Nov 25, 2019
@bep bep modified the milestones: v0.62, v0.63 Dec 11, 2019
@bep bep modified the milestones: v0.63, v0.64 Jan 22, 2020
@bep bep modified the milestones: v0.64, v0.65 Jan 30, 2020
@bep bep modified the milestones: v0.65, v0.66 Feb 18, 2020
@bep bep modified the milestones: v0.66, v0.67 Mar 2, 2020
@bep bep modified the milestones: v0.67, v0.68 Mar 9, 2020
@bep bep modified the milestones: v0.68, v0.69 Mar 20, 2020
@bep bep modified the milestones: v0.69, v0.70 Apr 8, 2020
@bep bep removed this from the v0.70 milestone Apr 28, 2020
@bep bep modified the milestones: v0.110.0, v0.111.0 Jan 26, 2023
@bep bep modified the milestones: v0.111.0, v0.112.0 Feb 15, 2023
@bep bep modified the milestones: v0.112.0, v0.113.0 Apr 15, 2023
@bep bep modified the milestones: v0.113.0, v0.114.0, v0.115.0 Jun 8, 2023
@bep bep modified the milestones: v0.115.0, v0.116.0 Jun 30, 2023
@bep bep modified the milestones: v0.116.0, v0.117.0 Aug 1, 2023
@bep bep modified the milestones: v0.117.0, v0.118.0 Aug 30, 2023
@bep bep modified the milestones: v0.118.0, v0.119.0 Sep 15, 2023
@bep bep modified the milestones: v0.119.0, v0.120.0 Oct 4, 2023
@bep bep modified the milestones: v0.120.0, v0.121.0 Oct 31, 2023
@bep bep modified the milestones: v0.121.0, v0.122.0 Dec 6, 2023
@jmooring
Copy link
Member

Closing in favor of #11391

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants