github.com/ownercz/glide@v0.13.4-0.20210823072704-79572d1b8747/docs/plugins.md (about)

     1  # Glide Plugins
     2  
     3  Glide supports a simple plugin system similar to Git.
     4  
     5  ## Existing Plugins
     6  
     7  Some plugins exist today for Glide including:
     8  
     9  * [glide-vc](https://github.com/sgotti/glide-vc) - The vendor cleaner allows you to strip files not needed for building your application from the `vendor/` directory.
    10  * [glide-brew](https://github.com/heewa/glide-brew) - Convert Go deps managed by glide to Homebrew resources to help you make brew formulas for you Go programs.
    11  * [glide-hash](https://github.com/mattfarina/glide-hash) - Generates a hash of the `glide.yaml` file compatible with Glides internal hash.
    12  * [glide-cleanup](https://github.com/ngdinhtoan/glide-cleanup) - Removing unused packages from the `glide.yaml` file.
    13  * [glide-pin](https://github.com/multiplay/glide-pin) - Take all dependencies from the `glide.lock` and pin them explicitly in the `glide.yaml` file.
    14  
    15  _Note, to add plugins to this list please create a pull request._
    16  
    17  ## How Plugins Work
    18  
    19  When Glide encounters a subcommand that it does not know, it will try to delegate it to another executable according to the following rules.
    20  
    21  Example:
    22  
    23  ```
    24  $ glide install # We know this command, so we execute it
    25  $ glide foo     # We don't know this command, so we look for a suitable
    26                  # plugin.
    27  ```
    28  
    29  In the example above, when glide receives the command `foo`, which it does not know, it will do the following:
    30  
    31  1. Transform the name from `foo` to `glide-foo`
    32  2. Look on the system `$PATH` for `glide-foo`. If it finds a program by that name, execute it...
    33  3. Or else, look at the current project's root for `glide-foo`. (That is, look in the same directory as `glide.yaml`). If found, execute it.
    34  4. If no suitable command is found, exit with an error.
    35  
    36  ## Writing a Glide Plugin
    37  
    38  A Glide plugin can be written in any language you wish, provided that it can be executed from the command line as a subprocess of Glide. The example included with Glide is a simple Bash script. We could just as easily write Go, Python, Perl, or even Java code (with a wrapper) to
    39  execute.
    40  
    41  A Glide plugin must be in one of two locations:
    42  
    43  1. Somewhere on the PATH
    44  2. In the same directory as `glide.yaml`
    45  
    46  It is recommended that system-wide Glide plugins go in `/usr/local/bin` or `$GOPATH/bin` while project-specific plugins go in the same directory as `glide.yaml`.
    47  
    48  ### Arguments and Flags
    49  
    50  Say Glide is executed like this:
    51  
    52  ```
    53  $ glide foo -name=Matt myfile.txt
    54  ```
    55  
    56  Glide will interpret this as a request to execute `glide-foo` with the arguments `-name=Matt myfile.txt`. It will not attempt to interpret those arguments or modify them in any way.
    57  
    58  Hypothetically, if Glide had a `-x` flag of its own, you could call this:
    59  
    60  ```
    61  $ glide -x foo -name=Matt myfile.txt
    62  ```
    63  
    64  In this case, glide would interpret and swollow the -x and pass the rest on to `glide-foo` as in the example above.
    65  
    66  ## Example Plugin
    67  
    68  File: glide-foo
    69  
    70  ```bash
    71  #!/bin/bash
    72  
    73  echo "Hello"
    74  ```