Граф коммитов

41 Коммитов

Автор SHA1 Сообщение Дата
Mislav Marohnić ce213d7c8f [env] Enable quoted values with spaces in $BROWSER
Makes possible:

    BROWSER='"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --extra --flag' hub browse

Fixes #2178
2019-06-28 21:41:17 +02:00
Mislav Marohnić d8973922ac Propagate global git arguments to Before/After chains
This fixes `hub -C mydir merge <URL>` and other commands that might be
invoked with git global arguments by ensuring that those global
arguments are also fowarded to any accompanying `git` commands within
`Before()` and `After()` chains.
2019-04-14 15:08:21 +02:00
Mislav Marohnić f0a1f617a5 Simplify some args preprocessing 2019-01-18 01:50:28 +01:00
Mislav Marohnić 01565e4fff Use ArgsParser for `hub help` 2019-01-18 01:50:28 +01:00
Mislav Marohnić c0db6e6f0c Use ArgsParser for commands that don't declare flags via pflag 2019-01-18 01:50:28 +01:00
Mislav Marohnić d7ef572416 Fix integration with git 2.18 shell completions
Wrap `git --list-cmds=others` command used by git built-in shell
completions to add a list of hub custom commands.

Fixes #1792
2018-07-07 12:38:02 +02:00
Mislav Marohnić 8d5a3e9103 Allow `args.Before/After` in combination with `NoForward` 2016-09-11 04:32:26 +02:00
Mislav Marohnić 0c4689c673 Fix printing content on Windows after successful run
The old `args.After("echo", ...)` approach won't cut it on Windows since
there is no `echo` executable. Thus, nothing was printed on Windows.

Instead, expand Args type with extra functionality that allows Go
callbacks after all commands in the chain have been run.

Also, the new `args.NoForward()` is now preferred to `os.Exit()` since
it's more descriptive and allows `defer` in the calling function.
2016-09-10 23:49:58 +02:00
Mislav Marohnić 40e0cd22fd Preserve git global flags when executing final git command
For git commands that are extended by hub, such as `git remote`, the
final git command would get executed without the git global flags
provided when executing hub in the first place.

This most notably broke the usage of `-C <dir>` flag.
2016-02-15 17:42:40 +13:00
Mislav Marohnić 21089ec0e4 Change `hub help` to display man pages when available
Instead of displaying plain text help, `hub help <command>` will now
search for man pages to display.

* If `man` is available, hub first tries to locate the local
  `../man/hub-<command>.1` file relative to the `hub` executable. If
  found, open it with `man`. If not, execute `man 1 hub-<command>`.

* Otherwise, resort to displaying plain text help.
2016-01-25 02:30:47 +11:00
Mislav Marohnić 7ea2575ed9 More efficient `--noop` detection
Avoids mutating `globalFlags` until a match has actually been found.
2015-07-08 21:35:34 -07:00
Mislav Marohnić 793cc18619 Encapsulate checking if a string looks like a flag 2015-07-08 21:03:31 -07:00
Mislav Marohnić 6dda96c251 Use constants instead of generating strings within loops 2015-07-08 21:00:33 -07:00
Mislav Marohnić a132ab2a3b Process `--noop` separately from `slurpGlobalFlags()`
This relieves `slurpGlobalFlags` of having too many duties
2015-07-08 11:09:15 -07:00
Mislav Marohnić c2d5e71913 Avoid depending on a hardcoded list of git global flags
We used to recognize git global flags based on a hardcoded list.
Whenever git added more global flags, we didn't support them in hub
until we updated the list.

Now, treat all flags coming before the subcommand as global flags. These
are the rules:

1. Initially, every argument except `--help` and `--version` that starts
   with a `-` is considered to be a global flag.

2. Additionally, `-c` and `-C` flags have a value.

3. When an argument appears that doesn't match the above rules, assume
   that it's the git subcommand and stop global args parsing.
2015-07-08 10:52:13 -07:00
Mislav Marohnić d45511c7aa Fix parsing arguments for `browse` command
After `browse` was indicated as "GitExtension: false", it now gets
automatically parsed by pflag library. That has an adverse effect that
it loses information about the `--` value being passed, since pflag
treats it as terminator value and swallows it silently.

Now, introduce the `args.Terminator` property to check if terminator was
present or not, and use that in `browse` to restore previous behavior.
2015-06-05 01:01:02 +02:00
Jingwen Owen Ou 2884da15b2 `Args.InsertParam` resets index to param size if it’s out of bound
`Args.InsertParam` panics about index out of bound if the index is larger than param size. These changes reset the index to param size for such case. This is equivalent to appending new items to the end.

This fixes #812.
2015-02-17 10:04:45 -08:00
Jingwen Owen Ou 1c1f48b1d0 Refactor global flags parsing 2015-01-14 09:53:15 -08:00
Jingwen Owen Ou 2699a6b718 Parse more global flags from by following https://github.com/github/hub/blob/1.12-stable/lib/hub/commands.rb#L961-L995 2015-01-14 09:34:04 -08:00
Jingwen Owen Ou 15be76697c Preserve global config flags specified with `-c` 2015-01-12 22:13:08 -08:00
Jingwen Owen Ou d99f308e2d Don’t trim empty string arguments when building command
Empty string arguments are removed when building an executable command, causing problems like https://github.com/github/hub/issues/725. However, we need to remove empty string arguments constructed from the commands layer, e.g., https://github.com/github/hub/blob/master/commands/browse.go#L112. We fix it by moving the removal logic to `Args.ToCmd`.
2014-12-09 08:44:03 -08:00
Jingwen Owen Ou d7bf266d45 Fix index out of range issue when parsing global flags
https://github.com/github/hub/issues/698
2014-11-24 15:29:45 -08:00
Owen Ou 158410a180 Delegate `git —-version` and `git —-help` to Hub 2014-10-22 14:02:11 -07:00
Jingwen Owen Ou 1b0d45420c Show git’s own help when running `hub help <command>` for git commands
This is to fix https://github.com/github/hub/issues/635
2014-10-19 09:56:46 -07:00
Jingwen Owen Ou 82dedbf6a0 Slurp `--noop` during parsing of args 2014-04-08 07:23:01 -07:00
Jingwen Owen Ou 498789a999 Change namespace to github/hub 2014-02-10 08:29:03 -08:00
David Calavera 51428d5449 Allow to chain subcommands using `command.Use(subcommandName, subcommand)`. 2013-12-28 21:24:08 -08:00
Jingwen Owen Ou 9d8749e1a5 Git merge is compatible with Hub spec 2013-12-10 13:42:54 -08:00
Jingwen Owen Ou 1eb87b822b Respect git alias 2013-08-16 07:16:59 -07:00
Jingwen Owen Ou f0c3b28ca0 Implement gh fetch 2013-07-10 16:29:26 -07:00
Jingwen Owen Ou 76e15dd6a3 Remove PrependParams 2013-07-05 13:51:54 -07:00
Jingwen Owen Ou 61bbf079a8 Fix all comands to aware of noop 2013-07-05 13:45:22 -07:00
Jingwen Owen Ou 87430090a9 Enable noop 2013-07-05 11:10:24 -07:00
Jingwen Owen Ou 8c364a71d5 Use better name for local var 2013-07-02 12:01:14 -07:00
Jingwen Owen Ou e3d6319fa5 Rename to Args#Params 2013-07-02 11:56:45 -07:00
Jingwen Owen Ou 13240c7021 Implement merge 2013-07-02 11:28:50 -07:00
Jingwen Owen Ou f2ee200ba4 Implement clone 2013-07-01 10:11:02 -07:00
Jingwen Owen Ou ff5b5ce6d7 Fallthrough to git if no commands match 2013-06-28 16:49:49 -07:00
Jingwen Owen Ou 24eec6ccfc Fix bugs in Args#Remove 2013-06-28 16:49:49 -07:00
Jingwen Owen Ou c294d2b615 Use Args for arguments 2013-06-28 16:49:49 -07:00
Jingwen Owen Ou e82093d6d6 Add Args 2013-06-28 16:49:49 -07:00