OSDN API client libraries (experimental-20171120) | 2017-11-20 17:44 |
SourceForge (Alexandria 2.5) | 2016-02-24 15:38 |
OSDN command line interface is currently experimental release.
On debian (ubuntu) system, you can install with following packages.
$ sudo apt-get install ruby ruby-ffi libcurl3
You can install by rubygem, type following on terminal.
$ gem install --no-ri --no-rdoc osdn-cli
Then check with "osdn help". If you cannot get help message, check your execute path. You may need to add $GEM_HOME/bin to $PATH.
$ osdn help osdn [global-options] <command> [command-options] [args] osdn help <command> Global Options: -h --help Show help message. use 'help <command>' for specific command. -v --verbose Increase log level (multiple) -q --quiet Decrease log level (multiple) Available Commands: help login Login and save access token. package Manipulate release package of project frs_mkdirs Make directory tree for current project release frs_upload Upload local file tree and create package/release implicitly. ping Test API request. vars Get/set request environment variable.
Just run 'help' to get guide message.
$ osdn help osdn [global-options] <command> [command-options] [args] osdn help <command> Global Options: -h --help Show help message. use 'help <command>' for specific command. -v --verbose Increase log level (multiple) -q --quiet Decrease log level (multiple) Available Commands: help login Login and save access token. package Manipulate frs packages of project release Manipulate frs releases of project relfile Manipulate frs files of project frs_mkdirs Make directory tree for current project release frs_upload Upload local file tree and create package/release implicitly. ping Test API request. vars Get/set request environment variable.
In addition, you can specify command to get command details.
$ osdn help package osdn package [opts] [list] osdn package [opts] create <new-package-name> osdn package [opts] update <numeric-package-id> [name] osdn package [opts] delete <numeric-package-id> Options: -f --format=<pretty|json> Set output format -p --project=<project> Target project (numeric id or name) -v --visibility=<public|private|hidden>
First of all, you need to login to API with 'login' command.
$ osdn login Access following URL to get auth code; https://osdn.net/account/oauth2ui/authorize?client_id=osdn-cli&......... Type your auth code: <== (Input your authcode here)
If you use graphical environment, osdn-cli try to launch graphical web browser. If not,
Login command stores access token into ~/.config/osdn/credential.yml.
osdn vars show [name] -- Show current variable osdn vars set <name> <value> -- Save variable to .osdn.vars
Get/Set request variable on current working directory. Variables are saved into '.osdn.vars' file.
Most commands automatically load variables from current working path, and use variables as default manipulation target.
For example, you need specify target project on 'package' command to listing packages;
$ osdn package [FATAL] No target project is specified. $ osdn package -p osdn-codes #14859 OSDN API client libraries (public, 1 releases) https://osdn.net/projects/osdn-codes/releases/p14859
If target project has been saved into ./.osdn.vars, you can commit target project option;
$ osdn vars show {} $ osdn vars set project osdn-codes $ osdn vars show {"project"=>"osdn-codes"} $ osdn package #14859 OSDN API client libraries (public, 1 releases) https://osdn.net/projects/osdn-codes/releases/p14859 $ rm .osdn.vars $ osdn package [FATAL] No target project is specified.
This command allow you to manipulate packages of project file release.
osdn package [opts] [list] osdn package [opts] create <new-package-name> osdn package [opts] update <numeric-package-id> [name] osdn package [opts] delete <numeric-package-id> Options: -f --format=<pretty|json> Set output format -p --project=<project> Target project (numeric id or name) -v --visibility=<public|private|hidden>
$ osdn package -p your-project list #12345 My First Package (public, 9 releases) https://osdn.net/projects/your-project/releases/p12345 #12346 My another package (public, 2 releases) https://osdn.net/projects/your-project/releases/p12346
You can commit '-p projname' option by setting target project by 'vars' command.
$ osdn package create 'new one' -p my-proj [INFO] New package has been created. #14132 new one (public, 0 releases) https://osdn.net/projects/my-proj/releases/p14132
Update a package specified by numeric ID. You can change name and visibility.
$ osdn package -p my-proj update 14132 renamed [INFO] Package 14132 has been updated. #14132 renamed (public, 0 releases) https://osdn.net/projects/my-proj/releases/p14132
$ osdn package -p my-proj delete 14132 [INFO] Package 14132 has been deleted.
This command allow you to manipulate releases of project file release. Operation details are almost same as package.
osdn release [opts] [list] osdn release [opts] create <new-release-name> osdn release [opts] update <numeric-release-id> [name] osdn release [opts] delete <numeric-release-id> Options: -f --format=<pretty|json> Set output format -p --project=<project> Target project (numeric id or name) --package=<package-id> Target package (numeric id) -v --visibility=<public|private|hidden>
This command allow you to manipulate files of project file release. Operation details are almost same as package.
osdn relfile [opts] [list] osdn relfile [opts] create <target-file> osdn relfile [opts] update <numeric-file-id> osdn relfile [opts] delete <numeric-file-id> Options: -f --format=<pretty|json> Set output format -p --project=<project> Target project (numeric id or name) --package=<package-id> Target package (numeric id) --release=<release-id> Target release (numeric id) -v --visibility=<public|private|hidden> --force-digest Calc local file digest forcibly
osdn frs_mkdirs [opts] [target_dir] Options: -p --project=<project> Target project (numeric id or name)
frs_mkdirs creates skeleton directories and save variables that reflects current file release hierarchy of your project.
If target_dir is omitted, frs_mkdirs create under current working directory.
You use created directories to upload new files by frs_upload.
$ osdn frs_mkdirs -p osdn-codes osdn-codes-files [INFO] Save variables to osdn-codes-files/.osdn.vars [INFO] Making directory for package OSDN API client libraries [INFO] Save variables to osdn-codes-files/OSDN API client libraries/.osdn.vars [INFO] Making directory for release experimental [INFO] Save variables to osdn-codes-files/OSDN API client libraries/experimental/.osdn.vars [INFO] Making directory for package osdn-codes [INFO] Save variables to osdn-codes-files/osdn-codes/.osdn.vars [INFO] Making directory for release unnamed_release [INFO] Save variables to osdn-codes-files/osdn-codes/unnamed_release/.osdn.vars
osdn frs_upload [opts] [target_dir] Options: -n --dry-run Do noting (use with global -v to inspect) -p --project=<project> Target project (numeric id or name) --package=<package-id> Target package (numeric id) --release=<release-id> Target release (numeric id) -v --visibility=<public|private|hidden> Default visibility for newly created items --force-digest Calc local file digest forcibly
You can upload local files to OSDN quickly by frs_upload command.
The command creates multiple packages/releases and uploads multiple files from local file hierarchy.
Note: This command will NEVER delete any packages, releases nor files from server. Just for creating/uploading new one.
You can create local hierarchy by frs_mkdirs command easily.
$ osdn -qq frs_mkdirs -p osdn-codes osdn-codes-files $ cd osdn-codes-files $ mkdir 'New package01' $ mkdir -p 'p02/New release on p02' $ cp -v /path/to/release.zip 'p02/New release on p02' '/path/to/release.zip' -> 'p02/New release on p02/release.zip' $ osdn frs_upload [INFO] Creating new package 'New package01' [INFO] Save variables to New package01/.osdn.vars New package 'New package01' has been created; https://osdn.net/projects/test/releases/p14134 [INFO] Creating new package 'p02' [INFO] Save variables to p02/.osdn.vars New package 'p02' has been created; https://osdn.net/projects/test/releases/p14135 [INFO] Creating new release 'New release on p02' [INFO] Save variables to p02/New release on p02/.osdn.vars New release 'New release on p02' has been created; https://osdn.net/projects/test/releases/60718 [INFO] Calculating digest for p02/New release on p02/release.zip... [INFO] Save variables to p02/New release on p02/.osdn.vars [INFO] Uploading file p02/New release on p02/release.zip (29 bytes) [INFO] Starting upload p02/New release on p02/release.zip... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 681 100 458 100 223 2552 1242 --:--:-- --:--:-- --:--:-- 2558 [INFO] Upload complete. New file 'p02/New release on p02/release.zip' has been uploaded; https://osdn.net/projects/test/downloads/60718/release.zip/
This command has been provided to test API request. You need to login before run ping.
This section describe to upload new release files by cli.
First of all, you need to login to API with cli.
Type "osdn login" to your terminal and get auth code from web browser.
$ osdn login Access following URL to get auth code; https://osdn.net/account/oauth2ui/authorize?client_id=osdn-cli&......... Type your auth code: <== (Input your authcode here)
First, create empty directory and set the directory to store files for uploading.
$ mkdir my-osdn-proj
Save target project (my-osdn-proj for this example) into the directory (.osdn.vas).
$ cd my-osdn-proj $ osdn vars set project my-osdn-proj
Run "osdn frs_mkdirs" to create package/release directories into current directory. If you have no packages on OSDN, this can be skipped.
$ osdn --verbose frs_mkdirs [INFO] Save variables to .osdn.vars [INFO] Making directory for package MyPackage1 [INFO] Save variables to MyPackage1/.osdn.vars [INFO] Making directory for release ver1.0 [INFO] Save variables to MyPackage1/ver1.0/.osdn.vars [INFO] Making directory for release ver1.1 [INFO] Save variables to MyPackage1/ver1.1/.osdn.vars
Finally, you get create new release directory and place files.
$ mkdir MyPakage1/ver1.2 $ cp -a ~/build/dist-1.2.tar.gz MyPackage1/ver1.2
Then run "osdn frs_upload" (with -v global option to show upload progress).
$ osdn frs_upload New release 'ver1.2' has been created; https://osdn.net/projects/my-osdn-proj/releases/123456 New file 'MyPackage1/ver1.2/dist-1.2.tar.gz' has been uploaded; https://osdn.net/projects/my-osdn-proj/downloads/123456/dist-1.2.tar.gz/