CLI Commands
PicGo can be used directly from the command line. After installing picgo globally, run picgo -h to see all available commands:
$ picgo -h
Usage: picgo [options] [command]
Options:
-v, --version output the version number
-d, --debug debug mode
-s, --silent silent mode
-c, --config <path> set config path
-h, --help output usage information
Commands:
install|add [options] <plugins...> install picgo plugin
uninstall|rm <plugins...> uninstall picgo plugin
update [options] <plugins...> update picgo plugin
set|config <module> [name] [configName] configure config of picgo modules
upload|u [input...] upload, go go go
use [module] [name] [configName] use modules of picgo
uploader [command] manage uploader configurations
i18n [lang] change picgo language
help [command] display help for commandWARNING
Starting from PicGo-Core v1.7.0, PicGo no longer bundles the legacy picgo init command. Use the standalone picgo-init command instead (see picgo-init section below).
Tip
Options wrapped in <> are required, and options wrapped in [] are optional. Some commands have aliases—for example, picgo upload can be shortened to picgo u.
The CLI is built with commander.js and inquirer.js. Below is a walkthrough of the commands and how to use them.
use
Select a PicGo module. There are three kinds of modules: 1) transformer 2) uploader 3) plugins
$ picgo use -h
Usage: use [module] [name] [configName]
use a module (uploader/transformer/plugin) of picgoPicGo ships with the following built-ins:
- transformer:
- path
- base64
- uploader:
- smms -> SM.MS
- tcyun -> Tencent Cloud COS
- upyun -> UpYun
- aliyun -> Alibaba Cloud OSS
- qiniu -> Qiniu Cloud
- imgur -> Imgur
- github -> GitHub
Tip
In most CLI workflows, you only need to select path as the PicGo transformer.
Use picgo use or picgo use uploader|transformer|plugins to pick the module you want. This opens an interactive prompt:
$ picgo use
? Use an uploader (Use arrow keys)
smms
❯ tcyun
weibo
github
qiniu
imgur
aliyun
(Move up and down to reveal more choices)Starting from PicGo-Core v1.8.0, uploaders support multiple named configs. If an uploader has multiple configs, the interactive flow will ask you to choose one. You can also specify it directly:
picgo use uploader <type> <configName>configName is matched case-insensitively.
After you choose, PicGo will upload using the selected module. Some modules need configuration before you can use them (for example, tokens/keys for an image host). In that case, use set|config (described below) to configure the module.
uploader 1.8.0+
Manage uploader configurations (multi-config).
picgo uploaderopens an interactive prompt (list/rename/copy/delete).picgo uploader list [type]lists configs (marks current uploader and default config).picgo uploader rename <type> <oldName> <newName>picgo uploader copy <type> <configName> <newConfigName>(does not switch current uploader)picgo uploader rm <type> <configName>
Config names are matched case-insensitively.
Examples:
picgo uploader list
picgo uploader list github
picgo uploader rename github Work Personal
picgo uploader copy github Work Staging
picgo uploader rm github Stagingset
Configure module settings. There are three kinds of modules: 1) transformer 2) uploader 3) plugins
$ picgo set -h
Usage: set [options] <module> [name] [configName]
configure config of picgo modules (uploader/transformer/plugin)
Options:
-h, --help output usage informationTip
Most of the time you only need to configure an uploader. You can run picgo set uploader (or picgo set uploader <type> [configName]) to jump straight into the interactive prompt.
Starting from PicGo-Core v1.8.0, set uploader works with uploader multi-config: you can choose an existing config (by name) or create a new one, and the saved config becomes the active config for that uploader.
For the detailed configuration fields of built-in uploaders (image hosts), refer to PicGo’s configuration wiki。
If an uploader/transformer/plugin has no configurable options, PicGo will still report success—this is expected.
$ picgo set transformer path
[PicGo SUCCESS]: Configure config successfully!upload|u
Upload images to an image host. Typically you upload local files (multiple files separated by spaces). You can also upload the first image from your clipboard.
Tip
Before uploading, make sure you’ve selected the right module with use and configured the target image host with set.
$ picgo u ./Test-example.jpg ./test-qiniu.png
[PicGo INFO]: Before transform
[PicGo INFO]: Transforming...
[PicGo INFO]: Before upload
[PicGo INFO]: Uploading...
[PicGo SUCCESS]:
https://i.loli.net/2018/09/06/5b9134645b9df.jpg
https://i.loli.net/2018/09/06/5b9134651af34.pngIf you don’t provide any input files, PicGo uploads the first image from your clipboard (due to cross-platform limitations it will be converted to PNG). This is especially handy for uploading screenshots.
$ picgo u
[PicGo INFO]: Before transform
[PicGo INFO]: Transforming...
[PicGo INFO]: Before upload
[PicGo INFO]: Uploading...
[PicGo SUCCESS]:
https://i.loli.net/2018/09/06/5b9134645b9df.jpginstall|add
Install PicGo plugins from npm. Plugin packages are named with the
picgo-plugin-prefix. When installing/uninstalling/updating, you only need to provide the short name (without thepicgo-plugin-prefix). You can install multiple plugins by separating them with spaces.
Tip
PicGo installs plugins into the directory where your config file lives. With the default config under ~/.picgo/, plugins will be installed into ~/.picgo/node_modules/.
You can search for PicGo plugins on npm. Plugins follow the naming pattern picgo-plugin-[name], and can be installed with:
picgo install [name]After installing, you can use picgo ch plugins to enable or disable the plugin.
uninstall|rm
Uninstall a PicGo plugin. PicGo will throw an error if the plugin is not installed.
picgo uninstall [name]update
Update an installed PicGo plugin. PicGo will throw an error if the plugin is not installed.
picgo update [name]i18n
Switch PicGo’s UI language. Supported languages:
- zh-CN (default)
- zh-TW
- en
Example:
picgo i18n en-v, --version
Run picgo -v or picgo --version to print the current PicGo version.
-d, --debug
Add -d or --debug to any valid command to enter debug mode. PicGo will print more detailed error information, including where the error occurred.
-c, --config
Add -c <path> to specify the PicGo config file path. The default config file is ~/.picgo/config.json.
Tip
PicGo loads plugins from the node_modules directory next to the config file.
-s, --silent
Add -s or --silent to any valid command to enter silent mode. PicGo will output nothing except error messages.
picgo-init
Download and generate a PicGo plugin development template.
Starting from PicGo-Core v1.7.0, this is provided by the standalone picgo-init command. See PicGo/PicGo-Init for installation and usage.
$ picgo-init -h
Usage: picgo-init <template> [project]
create picgo plugin's development templates
Options:
--offline use cached template
--debug debug mode
-h, --help display help for command
Examples:
# create a new project with an official template
$ picgo-init plugin my-project
# create a new project straight from a github template
$ picgo-init username/repo my-projectSimilar to vue-cli’s init, PicGo provides official templates. When running picgo-init, you can use plugin as the template name. Internally, if the template is not in username/repo form, PicGo automatically prefixes it with PicGo/picgo-template-.
This command helps you bootstrap a PicGo plugin quickly. For details, see Plugin Development.
