bin/aptly-cli in aptly_cli-0.0.2 vs bin/aptly-cli in aptly_cli-0.1.1

- old
+ new

@@ -2,93 +2,283 @@ require 'rubygems' require 'commander/import' require 'aptly_cli' -program :version, '0.0.1' +program :version, '0.1.1' program :description, 'Aptly repository API client' -command :file do |c| - c.syntax = 'aptly-cli file [options]' - c.summary = 'Upload package files temporarily to aptly service' - - c.description = 'All uploaded files are stored under <rootDir>/upload directory (see configuration). This directory would be created automatically if it doesn’t exist. Uploaded files are grouped by directories to support concurrent uploads from multiple package sources. Local repos add API can operate on directory (adding all files from directory) or on individual package files. By default, all successfully added package files would be removed.' +command :file_list do |c| + c.syntax = 'aptly-cli file_list [options]' + c.summary = 'List all directories that contain uploaded files' + c.description = 'List all directories' + c.example 'List all directories for file uploads', 'aptly-cli file_list' + c.option '--directory DIRECTORY', String, 'Directory to list packages on server' + c.action do |args, options| + aptly_command = AptlyCli::AptlyFile.new + if options.directory + puts aptly_command.file_get(options.directory) + else + puts aptly_command.file_dir() + end + end +end - c.example 'List of directories or files', 'aptly-cli file --list / or aptly-cli file --list /redis' - c.example 'Upload file to a directory', 'aptly-cli file --upload /tmp/redis/test_1.0_amd64.deb --dest_uri /redis' - c.example 'Delete file or directory', 'aptly-cli file --delete /test/test_1.0_amd64.deb' - c.option '--list URI_FILE_PATH', String, 'URI path to list files' - c.option '--upload LOCAL_FILE_PATH/PACKAGE', String, 'Path to package to upload' - c.option '--dest_uri URI_FILE_PATH', String, 'URI path to directory to upload into' - c.option '--delete URI_FILE_PATH/PACKAGE', String, 'URI path to directory to delete or specific package' +command :file_upload do |c| + c.syntax = 'aptly-cli file_upload [options]' + c.summary = 'Parameter --directory is upload directory name. Directory would be created if it doesn’t exist.' + c.description = 'File upload' + c.example 'description', 'aptly-cli file_upload --upload /local/copy/of/package.deb --directory /aptlyserver_directory/' + c.option '--directory DIRECTORY', String, 'Directory to load packages into' + c.option '--upload UPLOAD', String, 'Package(s) to upload' c.action do |args, options| aptly_command = AptlyCli::AptlyFile.new - puts aptly_command.file_get(options.list) if options.list - puts aptly_command.file_post(:file_uri => options.dest_uri, :package => options.upload, :local_file => options.upload) if options.upload and options.dest_uri - puts aptly_command.file_delete(options.delete) if options.delete + puts aptly_command.file_post(:file_uri => options.directory, :package => options.upload, :local_file => options.upload) end end -command :repo do |c| - c.syntax = 'aptly-cli repo [options]' - c.summary = '' - c.description = '' - c.example 'description', 'command example' - c.option '--some-switch', 'Some switch that does something' +command :file_delete do |c| + c.syntax = 'aptly-cli file_delete [options]' + c.summary = 'Deletes all files in upload directory and directory itself. Or delete just a file' + c.description = 'File delete' + c.example 'Delete package redis-server found in redis upload directory', 'aptly-cli file_delete --target /redis/redis-server_2.8.3_i386-cc1.deb' + c.option '--target TARGET', String, 'Path to directory or specific package to delete' c.action do |args, options| - # Do something or c.when_called Aptly-cli::Commands::Repo + aptly_command = AptlyCli::AptlyFile.new + puts aptly_command.file_delete(options.target) end end -command :snapshot do |c| - c.syntax = 'aptly-cli snapshot [options]' - c.summary = '' - c.description = '' - c.example 'description', 'command example' - c.option '--some-switch', 'Some switch that does something' +command :repo_create do |c| + c.syntax = 'aptly-cli repo_create [options]' + c.summary = 'Create a new repository, requires --name' + c.description = 'Create a new repository, requires --name' + c.example 'create repo', 'aptly-cli repo_create --name meagasoftware' + c.example 'creat repo with distribution set to "trusty"', 'aptly-cli repo_create --name megatronsoftware --default_distribution trusty' + c.option '--name NAME', String, 'Local repository name, required' + c.option '--comment COMMENT', String, 'Text describing local repository for the user' + c.option '--default_distribution DISTRIBUTION', String, 'Default distribution when publishing from this local repo' + c.option '--default_component COMPONENT', String, 'Default component when publishing from this local repo' c.action do |args, options| - # Do something or c.when_called Aptly-cli::Commands::Snapshot + puts options.name + aptly_command = AptlyCli::AptlyRepo.new + repo_options = { :name => options.name.to_s, + :comment => options.comment.to_s, + :DefaultDistribution => options.default_distribution.to_s, + :DefaultComponent => options.default_component.to_s } + puts aptly_command.repo_create(repo_options) end end -command :publish do |c| - c.syntax = 'aptly-cli publish [options]' - c.summary = '' - c.description = '' - c.example 'description', 'command example' - c.option '--some-switch', 'Some switch that does something' +command :repo_delete do |c| + c.syntax = 'aptly-cli repo_delete [options]' + c.summary = 'Delete a local repository, requires --name' + c.description = 'Delete a local repository, requires --name' + c.example 'description', 'aptly-cli repo_delete --name megatronsoftware' + c.option '--name NAME', String, 'Local repository name, required' + c.option '--force' c.action do |args, options| - # Do something or c.when_called Aptly-cli::Commands::Publish + aptly_command = AptlyCli::AptlyRepo.new + repo_options = { :name => options.name.to_s, + :force => options.force.to_s } + puts aptly_command.repo_delete(repo_options) end end -command :package do |c| - c.syntax = 'aptly-cli package [options]' - c.summary = '' - c.description = '' - c.example 'description', 'command example' - c.option '--some-switch', 'Some switch that does something' +command :repo_edit do |c| + c.syntax = 'aptly-cli repo_edit [options]' + c.summary = 'Edit a local repository metadata, requires --name' + c.description = 'Edit a local repository metadata, requires --name' + c.example 'description', 'aptly-cli repo_edit --name megatronsoftware --default_distribution trusty' + c.option '--name NAME', String, 'Local repository name, required' + c.option '--comment COMMENT', String, 'Edit repository comment' + c.option '--default_distribution DISTRIBUTION', String, 'Edit DefaultDistribution for repo' + c.option '--default_component COMPONENT', String, 'Edit DefaultComponent for repo' c.action do |args, options| - # Do something or c.when_called Aptly-cli::Commands::Package + aptly_command = AptlyCli::AptlyRepo.new + if options.default_distribution + repo_options = { :DefaultDistribution => options.default_distribution.to_s } + end + if options.default_component + repo_options = { :DefaultComponent => options.default_component.to_s } + end + if options.comment + repo_options = { :Comment => options.comment.to_s } + end + puts aptly_command.repo_edit(options.name.to_s, repo_options) end end +command :repo_list do |c| + c.syntax = 'aptly-cli repo_list [options]' + c.summary = 'Show list of currently available local repositories' + c.description = 'Show list of currently available local repositories' + c.example 'description', 'aptly-cli repo_list' + c.action do |args, options| + aptly_command = AptlyCli::AptlyRepo.new + puts aptly_command.repo_list() + end +end + +command :repo_package_query do |c| + c.syntax = 'aptly-cli repo_package_query [options]' + c.summary = 'List all packages in local repository or perform search on repository contents and return result., requires --name' + c.description = 'List all packages or search on repo contents, requires --name' + c.example 'description', 'aptly-cli repo_package_query --name megatronsoftware -query geoipupdate' + c.option '--name NAME', String, 'Local repository name, required' + c.option '--query QUERY', String, 'Package to query' + c.option '--with_deps', 'Return results with dependencies' + c.option '--format FORMAT', String, 'Format type to return, compact by default. "details" is an option' + c.action do |args, options| + aptly_command = AptlyCli::AptlyRepo.new + if options.query + repo_options = { :name => options.name.to_s, :query => options.query.to_s } + elsif options.with_deps and options.query.nil? + repo_options = { :name => options.name.to_s, :with_deps => options.with_deps.to_s } + elsif options.format and options.query.nil? + repo_options = { :name => options.name.to_s, :format => options.format.to_s } + else + repo_options = { :name => options.name.to_s } + end + puts aptly_command.repo_package_query(repo_options) + end +end + +command :repo_upload do |c| + c.syntax = 'aptly-cli repo_upload [options]' + c.summary = 'Import packages from files (uploaded using File Upload API) to the local repository. If directory specified, aptly would discover package files automatically. + + Adding same package to local repository is not an error. + + By default aptly would try to remove every successfully processed file and directory :dir (if it becomes empty after import).' + c.description = 'Import packages from files' + c.example 'description', 'aptly-cli repo_upload --name rocksoftware --dir rockpackages --noremove' + c.option '--name NAME', String, 'Local repository name, required' + c.option '--dir DIR', String, 'Directory where packages are stored via File API' + c.option '--file FILE', String, 'Specific file to upload, if not provided the entire directory of files will be uploaded' + c.option '--noremove', 'Flag to not remove any files that were uploaded via File API after repo upload' + c.option '--forcereplace', 'flag to replace file(s) already in the repo' + c.action do |args, options| + aptly_command = AptlyCli::AptlyRepo.new + puts aptly_command.repo_upload({ :name => options.name, :dir => options.dir, + :file => options.file, :noremove => options.noremove, + :forcereplace => options.forcereplace }) + end +end + +command :repo_show do |c| + c.syntax = 'aptly-cli repo_show [options]' + c.summary = 'Returns basic information about local repository' + c.description = 'Returns basic information about local repository, require --name' + c.example 'description', 'aptly-cli repo_show --name megatronsoftware' + c.option '--name NAME', String, 'Local repository name, required' + c.action do |args, options| + aptly_command = AptlyCli::AptlyRepo.new + puts aptly_command.repo_show(options.name) + end +end + +command :publish_drop do |c| + c.syntax = 'aptly-cli publish_drop [options]' + c.summary = 'Delete published repository, clean up files in published directory.' + c.description = 'Delete published repository' + c.example 'Delete publish repository called ', 'aptly-cli repo_list' + c.option '--prefix', String, 'prefix, optional' + c.option '--distribution', String, 'distribution' + c.option '--force', 'force published repository removal even if component cleanup fails' + c.action do |args, options| + aptly_command = AptlyCli::AptlyPublish.new + puts aptly_command.publish_drop({ :prefix => options.prefix, :distribution => options.distribution, :force => options.force }) + end +end + +command :publish_list do |c| + c.syntax = 'aptly-cli publish_list [options]' + c.summary = 'List published repositories.' + c.description = 'List published repositories.' + c.example 'List published repositories', 'aptly-cli publish_list' + c.action do |args, options| + aptly_command = AptlyCli::AptlyPublish.new + puts aptly_command.publish_list() + end +end + +command :publish_repo do |c| + c.syntax = 'aptly-cli publish_repo [options]' + c.summary = 'Publish local repository or snapshot under specified prefix. Storage might be passed in prefix as well, e.g. s3:packages/. To supply empty prefix, just remove last part (POST /api/publish/:prefix/<:repos>or<:snapshots>' + c.description = 'Publish local repository or snapshot under specified prefix' + c.example 'description', 'aptly-cli publish_repo --sourcekind local --name precise/megatronsoftware trusty/rocksoftware22 --architectures i386 amd64' + c.example 'description', 'aptly-cli publish_repo --sourcekind local --name megatronsoftware --architectures i386 amd64 --forceoverwrite true' + c.example 'description', 'aptly-cli publish_repo --sourcekind snapshot --name precise/rocksoftware300 --label test_snap' + c.example 'description', 'aptly-cli publish_repo --sourcekind snapshot --name precise/rocksoftware300 --origin testorigin' + c.example 'publish repo with signing keyring', 'aptly-cli publish_repo --sourcekind snapshot --name precise/rocksoftware300 --origin testorigin --gpg_keyring /etc/apt/trustdb.gpg' + c.option '--name NAME', String, 'Local repository name with optional component, required' + c.option '--sourcekind SOURCEKIND', String, 'Local for local repositories and snapshot for snapshots, required' + c.option '--distribution DISTRIBUTION', String, 'Distribution name, if missing aptly would try to guess from sources' + c.option '--label LABEL', String, 'value of Label: field in published repository stanza' + c.option '--origin ORIGIN', String, 'value of Origin: field in published repository stanza' + c.option '--forceoverwrite FORCEOVERWRITE', String, 'when publishing, overwrite files in pool/ directory without notice' + c.option '--architectures ARCHITECTURES', String, 'override list of published architectures' + c.option '--gpg_skip', 'Don’t sign published repository' + c.option '--gpg_batch', 'should be set if passing passphrase' + c.option '--gpg_key GPGKEY', String, 'gpg key name (local to aptly server/user)' + c.option '--gpg_keyring GPGKEYRING', String, 'gpg keyring filename (local to aptly server/user)' + c.option '--gpg_secret_keyring GPGSECRET', String, 'gpg secret keyring filename (local to aptly server/user)' + c.option '--gpg_passphrase GPGPASS', String, 'gpg key passphrase (if using over http, would be transmitted in clear text!)' + c.option '--gpg_passphrase_file GPGPASSFILE', String, 'gpg passphrase file (local to aptly server/user)' + c.action do |args, options| + aptly_command = AptlyCli::AptlyPublish.new + puts aptly_command.publish_repo(options.name, { :sourcekind => options.sourcekind, :label => options.label, :distribution => options.distribution, + :origin => options.origin, :forceoverwrite => options.forceoverwrite, + :architectures => options.architectures, :skip => options.gpg_skip, :batch => options.gpg_batch, + :gpgKey => options.gpg_key, :keyring => options.gpg_keyring, :secretKeyring => options.gpg_secret_keyring, + :passphrase => options.gpg_passphrase, :passphraseFile => options.gpg_passphrase_file }) + end +end + +command :publish_update do |c| + c.syntax = 'aptly-cli publish_update [options]' + c.summary = 'Update published repository. If local repository has been published, published repository would be updated to match local repository contents. If snapshots have been been published, it is possible to switch each component to new snapshot' + c.description = 'Update published repository' + c.example 'description', 'aptly-cli publish_update --sourcekind snapshot --name precise/rocksoftware300 --origin testorigin' + c.option '--prefix PREFIX', String, 'Publishing prefix, default root' + c.option '--distribution DISTRIBUTION', String, 'Distribution name' + c.option '--snapshots SNAPSHOTS', String, 'When updating published snapshots, list of objects component/name seperated by space' + c.option '--forceoverwrite FORCEOVERWRITE', String, 'When publishing, overwrite files in pool/ directory without notice' + c.option '--gpg_skip', 'Don’t sign published repository' + c.option '--gpg_batch', 'should be set if passing passphrase' + c.option '--gpg_key GPGKEY', String, 'gpg key name (local to aptly server/user)' + c.option '--gpg_keyring GPGKEYRING', String, 'gpg keyring filename (local to aptly server/user)' + c.option '--gpg_secret_keyring GPGSECRET', String, 'gpg secret keyring filename (local to aptly server/user)' + c.option '--gpg_passphrase GPGPASS', String, 'gpg key passphrase (if using over http, would be transmitted in clear text!)' + c.option '--gpg_passphrase_file GPGPASSFILE', String, 'gpg passphrase file (local to aptly server/user)' + c.action do |args, options| + aptly_command = AptlyCli::AptlyPublish.new + puts aptly_command.publish_update(options.snapshots, { :prefix => options.prefix, :distribution => options.distribution, :forceoverwrite => options.forceoverwrite, + :skip => options.gpg_skip, :batch => options.gpg_batch, :gpgKey => options.gpg_key, + :keyring => options.gpg_keyring, :secretKeyring => options.gpg_secret_keyring, + :passphrase => options.gpg_passphrase, :passphraseFile => options.gpg_passphrase_file }) + end +end + command :graph do |c| c.syntax = 'aptly-cli graph [options]' - c.summary = '' - c.description = '' - c.example 'description', 'command example' - c.option '--some-switch', 'Some switch that does something' + c.summary = 'Download a graph of repository layout. Current options are "svg" and "png"' + c.description = 'Download an svg or png graph of repository layout' + c.example 'description', 'aptly-cli graph png > ~/repo_graph.png' + c.option '--type GRAPH_TYPE', String, 'Type of graph to download, present options are png or svg' c.action do |args, options| - # Do something or c.when_called Aptly-cli::Commands::Graph + aptly_command = AptlyCli::AptlyMisc.new + puts aptly_command.get_graph(options.type) end end command :version do |c| c.syntax = 'aptly-cli version' c.description = 'Display aptly server version' c.example 'description', 'aptly-cli version' c.action do |args, options| - # Do something or c.when_called Aptly-cli::Commands::Version + aptly_command = AptlyCli::AptlyMisc.new + puts aptly_command.get_version() end end