{"action":"closed","number":5129,"pull_request":{"url":"https://api.github.com/repos/rust-lang/cargo/pulls/5129","id":173187594,"html_url":"https://github.com/rust-lang/cargo/pull/5129","diff_url":"https://github.com/rust-lang/cargo/pull/5129.diff","patch_url":"https://github.com/rust-lang/cargo/pull/5129.patch","issue_url":"https://api.github.com/repos/rust-lang/cargo/issues/5129","number":5129,"state":"closed","locked":false,"title":"WIP: switch to clap","user":{"login":"matklad","id":1711539,"avatar_url":"https://avatars3.githubusercontent.com/u/1711539?v=4","gravatar_id":"","url":"https://api.github.com/users/matklad","html_url":"https://github.com/matklad","followers_url":"https://api.github.com/users/matklad/followers","following_url":"https://api.github.com/users/matklad/following{/other_user}","gists_url":"https://api.github.com/users/matklad/gists{/gist_id}","starred_url":"https://api.github.com/users/matklad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matklad/subscriptions","organizations_url":"https://api.github.com/users/matklad/orgs","repos_url":"https://api.github.com/users/matklad/repos","events_url":"https://api.github.com/users/matklad/events{/privacy}","received_events_url":"https://api.github.com/users/matklad/received_events","type":"User","site_admin":false},"body":"This PR is a proof-of-concept for rewrite of Cargo's argument parsing from docopt into clap ([the previous episode](https://github.com/rust-lang/cargo/pull/3575)).\r\n\r\nOnly two commands (bench and build) are ported over to clap, and the code is of \"prototype\" quality :) However, I'd love to get general feedback about the general approach before moving forward with implementation. \r\n\r\nThe main problem which this aims to solve is excessive code duplication between various Cargo commands. In particular, when commands share some options (which often is the case!) each command has to repeat code, responsible for handling of these options. Annoyingly, the options are almost, but not quite, the same: for example, different commands have different descriptions of options (\"test all packages\" vs \"benchmark all packages\").\r\n\r\nThis actually makes quite difficult to use something like `structopt` or `clap-derive` for the task, so I've decided to go with the usual stringly-typed approach of clap. \r\n\r\nThe idea is to have a giant `clap::App` with all build-in subcommands, share definitons of options by providing `.arg_color()`-like extensions for defining options, and share code by providing `fn worksapce_from_options(args: &ArgMatches)`-like functions. Although only two commands, `build` and `bench`, are ported, they do share a significant chunk of code. \r\n\r\nWhy we might want to do switch to clap:\r\n\r\n* reduce code duplication\r\n* have sane subcommand handling\r\n* use the same library for parsing options in rustup and Cargo\r\n* take advantage of various clap features for input validation, completion generation, text-wrapping and what not\r\n\r\nWhy we might want to maintain the status quo (docopt):\r\n\r\n* less work right now (but more maintenance work down the road)\r\n* understanding what a particular command is doing might be easier with docopt (though the complexity to emulate subcommands with docopt I think compensates for this :-) )\r\n* There's a high chance that we won't be able to replicate **all** quirks of the current implementations, so, for some edge cases, the arguments might get interpreted differently. \r\n\r\n:clap: :clap: :clap:\r\n\r\nr? @alexcrichton  ","created_at":"2018-03-06T15:14:43Z","updated_at":"2018-03-07T06:34:30Z","closed_at":"2018-03-07T06:34:30Z","merged_at":null,"merge_commit_sha":"bf2181f60d6ed349a59a4a34a3e475737157fda6","assignee":{"login":"alexcrichton","id":64996,"avatar_url":"https://avatars1.githubusercontent.com/u/64996?v=4","gravatar_id":"","url":"https://api.github.com/users/alexcrichton","html_url":"https://github.com/alexcrichton","followers_url":"https://api.github.com/users/alexcrichton/followers","following_url":"https://api.github.com/users/alexcrichton/following{/other_user}","gists_url":"https://api.github.com/users/alexcrichton/gists{/gist_id}","starred_url":"https://api.github.com/users/alexcrichton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexcrichton/subscriptions","organizations_url":"https://api.github.com/users/alexcrichton/orgs","repos_url":"https://api.github.com/users/alexcrichton/repos","events_url":"https://api.github.com/users/alexcrichton/events{/privacy}","received_events_url":"https://api.github.com/users/alexcrichton/received_events","type":"User","site_admin":false},"assignees":[{"login":"alexcrichton","id":64996,"avatar_url":"https://avatars1.githubusercontent.com/u/64996?v=4","gravatar_id":"","url":"https://api.github.com/users/alexcrichton","html_url":"https://github.com/alexcrichton","followers_url":"https://api.github.com/users/alexcrichton/followers","following_url":"https://api.github.com/users/alexcrichton/following{/other_user}","gists_url":"https://api.github.com/users/alexcrichton/gists{/gist_id}","starred_url":"https://api.github.com/users/alexcrichton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexcrichton/subscriptions","organizations_url":"https://api.github.com/users/alexcrichton/orgs","repos_url":"https://api.github.com/users/alexcrichton/repos","events_url":"https://api.github.com/users/alexcrichton/events{/privacy}","received_events_url":"https://api.github.com/users/alexcrichton/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/rust-lang/cargo/pulls/5129/commits","review_comments_url":"https://api.github.com/repos/rust-lang/cargo/pulls/5129/comments","review_comment_url":"https://api.github.com/repos/rust-lang/cargo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rust-lang/cargo/issues/5129/comments","statuses_url":"https://api.github.com/repos/rust-lang/cargo/statuses/dc74e503530f4a4d32aa6d3c14959e7a501b9f36","head":{"label":"matklad:clap","ref":"clap","sha":"dc74e503530f4a4d32aa6d3c14959e7a501b9f36","user":{"login":"matklad","id":1711539,"avatar_url":"https://avatars3.githubusercontent.com/u/1711539?v=4","gravatar_id":"","url":"https://api.github.com/users/matklad","html_url":"https://github.com/matklad","followers_url":"https://api.github.com/users/matklad/followers","following_url":"https://api.github.com/users/matklad/following{/other_user}","gists_url":"https://api.github.com/users/matklad/gists{/gist_id}","starred_url":"https://api.github.com/users/matklad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matklad/subscriptions","organizations_url":"https://api.github.com/users/matklad/orgs","repos_url":"https://api.github.com/users/matklad/repos","events_url":"https://api.github.com/users/matklad/events{/privacy}","received_events_url":"https://api.github.com/users/matklad/received_events","type":"User","site_admin":false},"repo":{"id":47427273,"name":"cargo","full_name":"matklad/cargo","owner":{"login":"matklad","id":1711539,"avatar_url":"https://avatars3.githubusercontent.com/u/1711539?v=4","gravatar_id":"","url":"https://api.github.com/users/matklad","html_url":"https://github.com/matklad","followers_url":"https://api.github.com/users/matklad/followers","following_url":"https://api.github.com/users/matklad/following{/other_user}","gists_url":"https://api.github.com/users/matklad/gists{/gist_id}","starred_url":"https://api.github.com/users/matklad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matklad/subscriptions","organizations_url":"https://api.github.com/users/matklad/orgs","repos_url":"https://api.github.com/users/matklad/repos","events_url":"https://api.github.com/users/matklad/events{/privacy}","received_events_url":"https://api.github.com/users/matklad/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/matklad/cargo","description":"The Rust package manager","fork":true,"url":"https://api.github.com/repos/matklad/cargo","forks_url":"https://api.github.com/repos/matklad/cargo/forks","keys_url":"https://api.github.com/repos/matklad/cargo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/matklad/cargo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/matklad/cargo/teams","hooks_url":"https://api.github.com/repos/matklad/cargo/hooks","issue_events_url":"https://api.github.com/repos/matklad/cargo/issues/events{/number}","events_url":"https://api.github.com/repos/matklad/cargo/events","assignees_url":"https://api.github.com/repos/matklad/cargo/assignees{/user}","branches_url":"https://api.github.com/repos/matklad/cargo/branches{/branch}","tags_url":"https://api.github.com/repos/matklad/cargo/tags","blobs_url":"https://api.github.com/repos/matklad/cargo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/matklad/cargo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/matklad/cargo/git/refs{/sha}","trees_url":"https://api.github.com/repos/matklad/cargo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/matklad/cargo/statuses/{sha}","languages_url":"https://api.github.com/repos/matklad/cargo/languages","stargazers_url":"https://api.github.com/repos/matklad/cargo/stargazers","contributors_url":"https://api.github.com/repos/matklad/cargo/contributors","subscribers_url":"https://api.github.com/repos/matklad/cargo/subscribers","subscription_url":"https://api.github.com/repos/matklad/cargo/subscription","commits_url":"https://api.github.com/repos/matklad/cargo/commits{/sha}","git_commits_url":"https://api.github.com/repos/matklad/cargo/git/commits{/sha}","comments_url":"https://api.github.com/repos/matklad/cargo/comments{/number}","issue_comment_url":"https://api.github.com/repos/matklad/cargo/issues/comments{/number}","contents_url":"https://api.github.com/repos/matklad/cargo/contents/{+path}","compare_url":"https://api.github.com/repos/matklad/cargo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/matklad/cargo/merges","archive_url":"https://api.github.com/repos/matklad/cargo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/matklad/cargo/downloads","issues_url":"https://api.github.com/repos/matklad/cargo/issues{/number}","pulls_url":"https://api.github.com/repos/matklad/cargo/pulls{/number}","milestones_url":"https://api.github.com/repos/matklad/cargo/milestones{/number}","notifications_url":"https://api.github.com/repos/matklad/cargo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/matklad/cargo/labels{/name}","releases_url":"https://api.github.com/repos/matklad/cargo/releases{/id}","deployments_url":"https://api.github.com/repos/matklad/cargo/deployments","created_at":"2015-12-04T20:30:04Z","updated_at":"2016-01-29T00:49:42Z","pushed_at":"2018-03-06T22:16:47Z","git_url":"git://github.com/matklad/cargo.git","ssh_url":"git@github.com:matklad/cargo.git","clone_url":"https://github.com/matklad/cargo.git","svn_url":"https://github.com/matklad/cargo","homepage":"http://crates.io/","size":14735,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":2,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rust-lang:master","ref":"master","sha":"c7219374061c514ecf40d918ba689ea36ee94fbd","user":{"login":"rust-lang","id":5430905,"avatar_url":"https://avatars1.githubusercontent.com/u/5430905?v=4","gravatar_id":"","url":"https://api.github.com/users/rust-lang","html_url":"https://github.com/rust-lang","followers_url":"https://api.github.com/users/rust-lang/followers","following_url":"https://api.github.com/users/rust-lang/following{/other_user}","gists_url":"https://api.github.com/users/rust-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/rust-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rust-lang/subscriptions","organizations_url":"https://api.github.com/users/rust-lang/orgs","repos_url":"https://api.github.com/users/rust-lang/repos","events_url":"https://api.github.com/users/rust-lang/events{/privacy}","received_events_url":"https://api.github.com/users/rust-lang/received_events","type":"Organization","site_admin":false},"repo":{"id":17420913,"name":"cargo","full_name":"rust-lang/cargo","owner":{"login":"rust-lang","id":5430905,"avatar_url":"https://avatars1.githubusercontent.com/u/5430905?v=4","gravatar_id":"","url":"https://api.github.com/users/rust-lang","html_url":"https://github.com/rust-lang","followers_url":"https://api.github.com/users/rust-lang/followers","following_url":"https://api.github.com/users/rust-lang/following{/other_user}","gists_url":"https://api.github.com/users/rust-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/rust-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rust-lang/subscriptions","organizations_url":"https://api.github.com/users/rust-lang/orgs","repos_url":"https://api.github.com/users/rust-lang/repos","events_url":"https://api.github.com/users/rust-lang/events{/privacy}","received_events_url":"https://api.github.com/users/rust-lang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rust-lang/cargo","description":"The Rust package manager","fork":false,"url":"https://api.github.com/repos/rust-lang/cargo","forks_url":"https://api.github.com/repos/rust-lang/cargo/forks","keys_url":"https://api.github.com/repos/rust-lang/cargo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rust-lang/cargo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rust-lang/cargo/teams","hooks_url":"https://api.github.com/repos/rust-lang/cargo/hooks","issue_events_url":"https://api.github.com/repos/rust-lang/cargo/issues/events{/number}","events_url":"https://api.github.com/repos/rust-lang/cargo/events","assignees_url":"https://api.github.com/repos/rust-lang/cargo/assignees{/user}","branches_url":"https://api.github.com/repos/rust-lang/cargo/branches{/branch}","tags_url":"https://api.github.com/repos/rust-lang/cargo/tags","blobs_url":"https://api.github.com/repos/rust-lang/cargo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rust-lang/cargo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rust-lang/cargo/git/refs{/sha}","trees_url":"https://api.github.com/repos/rust-lang/cargo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rust-lang/cargo/statuses/{sha}","languages_url":"https://api.github.com/repos/rust-lang/cargo/languages","stargazers_url":"https://api.github.com/repos/rust-lang/cargo/stargazers","contributors_url":"https://api.github.com/repos/rust-lang/cargo/contributors","subscribers_url":"https://api.github.com/repos/rust-lang/cargo/subscribers","subscription_url":"https://api.github.com/repos/rust-lang/cargo/subscription","commits_url":"https://api.github.com/repos/rust-lang/cargo/commits{/sha}","git_commits_url":"https://api.github.com/repos/rust-lang/cargo/git/commits{/sha}","comments_url":"https://api.github.com/repos/rust-lang/cargo/comments{/number}","issue_comment_url":"https://api.github.com/repos/rust-lang/cargo/issues/comments{/number}","contents_url":"https://api.github.com/repos/rust-lang/cargo/contents/{+path}","compare_url":"https://api.github.com/repos/rust-lang/cargo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rust-lang/cargo/merges","archive_url":"https://api.github.com/repos/rust-lang/cargo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rust-lang/cargo/downloads","issues_url":"https://api.github.com/repos/rust-lang/cargo/issues{/number}","pulls_url":"https://api.github.com/repos/rust-lang/cargo/pulls{/number}","milestones_url":"https://api.github.com/repos/rust-lang/cargo/milestones{/number}","notifications_url":"https://api.github.com/repos/rust-lang/cargo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rust-lang/cargo/labels{/name}","releases_url":"https://api.github.com/repos/rust-lang/cargo/releases{/id}","deployments_url":"https://api.github.com/repos/rust-lang/cargo/deployments","created_at":"2014-03-04T23:20:42Z","updated_at":"2018-03-07T04:31:00Z","pushed_at":"2018-03-07T00:55:14Z","git_url":"git://github.com/rust-lang/cargo.git","ssh_url":"git@github.com:rust-lang/cargo.git","clone_url":"https://github.com/rust-lang/cargo.git","svn_url":"https://github.com/rust-lang/cargo","homepage":"https://doc.rust-lang.org/cargo","size":17072,"stargazers_count":2935,"watchers_count":2935,"language":"Rust","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":725,"mirror_url":null,"archived":false,"open_issues_count":616,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":725,"open_issues":616,"watchers":2935,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rust-lang/cargo/pulls/5129"},"html":{"href":"https://github.com/rust-lang/cargo/pull/5129"},"issue":{"href":"https://api.github.com/repos/rust-lang/cargo/issues/5129"},"comments":{"href":"https://api.github.com/repos/rust-lang/cargo/issues/5129/comments"},"review_comments":{"href":"https://api.github.com/repos/rust-lang/cargo/pulls/5129/comments"},"review_comment":{"href":"https://api.github.com/repos/rust-lang/cargo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rust-lang/cargo/pulls/5129/commits"},"statuses":{"href":"https://api.github.com/repos/rust-lang/cargo/statuses/dc74e503530f4a4d32aa6d3c14959e7a501b9f36"}},"author_association":"MEMBER","merged":false,"mergeable":true,"rebaseable":true,"mergeable_state":"unstable","merged_by":null,"comments":7,"review_comments":0,"maintainer_can_modify":false,"commits":1,"additions":457,"deletions":12,"changed_files":5}}
{"actor":{"display_login":"matklad"}}