github.com/anthonymayer/glide@v0.0.0-20160224162501-bff8b50d232e/docs/plugins.md (about) 1 # Glide Plugins 2 3 (Not to be confused with Glade Plugins. Pew.) 4 5 Glide supports a simple plugin system similar to Git. When Glide 6 encounters a subcommand that it does not know, it will try to delegate 7 it to another executable according to the following rules. 8 9 Example: 10 11 ``` 12 $ glide in # We know this command, so we execute it 13 $ glide foo # We don't know this command, so we look for a suitable 14 # plugin. 15 ``` 16 17 In the example above, when glide receives the command `foo`, which it 18 does not know, it will do the following: 19 20 1. Transform the name from `foo` to `glide-foo` 21 2. Look on the system `$PATH` for `glide-foo`. If it finds a program by 22 that name, execute it... 23 3. Or else, look at the current project's root for `glide-foo`. (That 24 is, look in the same directory as glide.yaml). If found, execute it. 25 4. If no suitable command is found, exit with an error. 26 27 ## Writing a Glide Plugin 28 29 A Glide plugin can be written in any language you wish, provided that it 30 can be executed from the command line as a subprocess of Glide. The 31 example included with Glide is a simple Bash script. We could just as 32 easily write Go, Python, Perl, or even Java code (with a wrapper) to 33 execute. 34 35 A glide plugin must be in one of two locations: 36 37 1. Somewhere on the PATH (including `$GLIDE_PATH/_vendor/bin`) 38 2. In the same directory as `glide.yaml` 39 40 It is recommended that system-wide Glide plugins go in `/usr/local/bin` 41 while project-specific plugins go in the same directory as `glide.yaml`. 42 43 ### Arguments and Flags 44 45 Say Glide is executed like this: 46 47 ``` 48 $ glide foo -name=Matt myfile.txt 49 ``` 50 51 Glide will interpret this as a request to execute `glide-foo` with the 52 arguments `-name=Matt myfile.txt`. It will not attempt to interpret 53 those arguments or modify them in any way. 54 55 Hypothetically, if Glide had a `-x` flag of its own, you could call 56 this: 57 58 ``` 59 $ glide -x foo -name=Matt myfile.txt 60 ``` 61 62 In this case, glide would interpret and swollow the -x and pass the rest 63 on to glide-foo as in the example above. 64 65 ### Environment Variables 66 67 When Glide executes a plugin, it passes through all of its environment 68 variables, including... 69 70 - GOPATH: Gopath 71 - PATH: Executable paths 72 - GLIDE_GOPATH: Gopath (in case GOPATH gets overridden by another 73 script) 74 - GLIDE_PROJECT: The path to the project 75 - GLIDE_YAML: The path to the project's YAML 76 - ALREADY_GLIDING: 1 if we are in a `glide in` session. 77 78 ## Example Plugin 79 80 File: glide-foo 81 82 ```bash 83 #!/bin/bash 84 85 echo "Hello" 86 ``` 87 88 Yup, that's it. Also see `glide-example-plugin` for a bigger example.