{"action":"created","comment":{"url":"https://api.github.com/repos/ProtonLights/cli/pulls/comments/70018800","id":70018800,"diff_hunk":"@@ -0,0 +1,176 @@\n+\n+use project_types::{Sequence, User};\n+use error::Error;\n+use Permission;\n+use PermissionEnum;\n+\n+\n+/// Structure to represent a Proton Project.\n+/// This is what will be written to a Protonfile at the project root.\n+#[derive(Clone, Debug, PartialEq, Eq, RustcEncodable, RustcDecodable)]\n+pub struct Project {\n+    pub name: String,\n+    pub users: Vec<User>,\n+    pub sequences: Vec<Sequence>,\n+}\n+\n+impl Project {\n+    /// Creates an empty project with the given admin user\n+    pub fn empty(admin_pub_key: &str) -> Result<Project, Error> {\n+\n+        let mut admin = try!(User::new(\"admin\".as_ref(), &admin_pub_key));\n+        let admin_permission = try!(Permission::new(PermissionEnum::GrantPerm, None::<String>));\n+        let edit_proj_permission = try!(Permission::new(PermissionEnum::EditProj, None::<String>));\n+        admin.add_permission(admin_permission);\n+        admin.add_permission(edit_proj_permission);\n+\n+        Ok(Project {\n+            name: \"New Project\".to_owned(),\n+            users: vec![admin],\n+            sequences: Vec::new(),\n+        })\n+    }\n+\n+    /// Finds a sequence by its name\n+    /// Returns the sequence if found, else None\n+    pub fn find_sequence_by_name(&self, name: &str) -> Option<&Sequence> {\n+        for s in &self.sequences {\n+            if s.name == name {\n+                return Some(s);\n+            }\n+        }\n+\n+        None::<&Sequence>\n+    }\n+\n+    /// Finds a user with the given public key\n+    /// Returns the user if found, else None\n+    fn find_user_by_public_key(&self, pub_key: &str) -> Option<&User> {\n+        for u in &self.users {\n+            if u.public_key == pub_key {\n+                return Some(u);\n+            }\n+        }\n+        None::<&User>\n+    }\n+\n+    /// Finds a user with the given name\n+    /// Returns the user if found, else None\n+    // TODO: make private?\n+    pub fn find_user_by_name(&self, name: &str) -> Option<&User> {\n+        for u in &self.users {\n+            if u.name == name {\n+                return Some(u);\n+            }\n+        }\n+        None::<&User>\n+    }\n+\n+    /// Finds a user in the users vector\n+    /// Returns true if found, else false\n+    pub fn user_exists(&self, user: &User) -> bool {\n+        for u in &self.users {\n+            if user == u {\n+                return true;\n+            }\n+        }\n+        return false;\n+    }\n+\n+    /// Adds a user to the project\n+    /// Returns a new project with the user added\n+    pub fn add_user(&self, name: &str, pub_key: &str) -> Result<Project, Error> {\n+        \n+        let user = try!(User::new(name, pub_key));\n+\n+        if self.find_user_by_name(name).is_some() ||\n+           self.find_user_by_public_key(pub_key).is_some() {\n+           ","path":"src/project_types/project.rs","position":88,"original_position":88,"commit_id":"021569af45b8d66c617a56d66d19a4a6fcdbb336","original_commit_id":"021569af45b8d66c617a56d66d19a4a6fcdbb336","user":{"login":"rjayatilleka","id":5570434,"avatar_url":"https://avatars.githubusercontent.com/u/5570434?v=3","gravatar_id":"","url":"https://api.github.com/users/rjayatilleka","html_url":"https://github.com/rjayatilleka","followers_url":"https://api.github.com/users/rjayatilleka/followers","following_url":"https://api.github.com/users/rjayatilleka/following{/other_user}","gists_url":"https://api.github.com/users/rjayatilleka/gists{/gist_id}","starred_url":"https://api.github.com/users/rjayatilleka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rjayatilleka/subscriptions","organizations_url":"https://api.github.com/users/rjayatilleka/orgs","repos_url":"https://api.github.com/users/rjayatilleka/repos","events_url":"https://api.github.com/users/rjayatilleka/events{/privacy}","received_events_url":"https://api.github.com/users/rjayatilleka/received_events","type":"User","site_admin":false},"body":"Extra blank line","created_at":"2016-07-08T02:36:30Z","updated_at":"2016-07-08T02:36:30Z","html_url":"https://github.com/ProtonLights/cli/pull/27#discussion_r70018800","pull_request_url":"https://api.github.com/repos/ProtonLights/cli/pulls/27","_links":{"self":{"href":"https://api.github.com/repos/ProtonLights/cli/pulls/comments/70018800"},"html":{"href":"https://github.com/ProtonLights/cli/pull/27#discussion_r70018800"},"pull_request":{"href":"https://api.github.com/repos/ProtonLights/cli/pulls/27"}}},"pull_request":{"url":"https://api.github.com/repos/ProtonLights/cli/pulls/27","id":76371089,"html_url":"https://github.com/ProtonLights/cli/pull/27","diff_url":"https://github.com/ProtonLights/cli/pull/27.diff","patch_url":"https://github.com/ProtonLights/cli/pull/27.patch","issue_url":"https://api.github.com/repos/ProtonLights/cli/issues/27","number":27,"state":"open","locked":false,"title":"User permissions","user":{"login":"bookdude13","id":6414232,"avatar_url":"https://avatars.githubusercontent.com/u/6414232?v=3","gravatar_id":"","url":"https://api.github.com/users/bookdude13","html_url":"https://github.com/bookdude13","followers_url":"https://api.github.com/users/bookdude13/followers","following_url":"https://api.github.com/users/bookdude13/following{/other_user}","gists_url":"https://api.github.com/users/bookdude13/gists{/gist_id}","starred_url":"https://api.github.com/users/bookdude13/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bookdude13/subscriptions","organizations_url":"https://api.github.com/users/bookdude13/orgs","repos_url":"https://api.github.com/users/bookdude13/repos","events_url":"https://api.github.com/users/bookdude13/events{/privacy}","received_events_url":"https://api.github.com/users/bookdude13/received_events","type":"User","site_admin":false},"body":"Addresses #24. It's a big one. @rjayatilleka if it takes you a while to get through this, no problem. Don't rush it.","created_at":"2016-07-06T02:33:10Z","updated_at":"2016-07-08T02:36:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6ce43e8a2ac0b574664aacb6ea83ed27748c0346","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/ProtonLights/cli/pulls/27/commits","review_comments_url":"https://api.github.com/repos/ProtonLights/cli/pulls/27/comments","review_comment_url":"https://api.github.com/repos/ProtonLights/cli/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ProtonLights/cli/issues/27/comments","statuses_url":"https://api.github.com/repos/ProtonLights/cli/statuses/021569af45b8d66c617a56d66d19a4a6fcdbb336","head":{"label":"ProtonLights:iss24","ref":"iss24","sha":"021569af45b8d66c617a56d66d19a4a6fcdbb336","user":{"login":"ProtonLights","id":16180225,"avatar_url":"https://avatars.githubusercontent.com/u/16180225?v=3","gravatar_id":"","url":"https://api.github.com/users/ProtonLights","html_url":"https://github.com/ProtonLights","followers_url":"https://api.github.com/users/ProtonLights/followers","following_url":"https://api.github.com/users/ProtonLights/following{/other_user}","gists_url":"https://api.github.com/users/ProtonLights/gists{/gist_id}","starred_url":"https://api.github.com/users/ProtonLights/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ProtonLights/subscriptions","organizations_url":"https://api.github.com/users/ProtonLights/orgs","repos_url":"https://api.github.com/users/ProtonLights/repos","events_url":"https://api.github.com/users/ProtonLights/events{/privacy}","received_events_url":"https://api.github.com/users/ProtonLights/received_events","type":"Organization","site_admin":false},"repo":{"id":53916850,"name":"cli","full_name":"ProtonLights/cli","owner":{"login":"ProtonLights","id":16180225,"avatar_url":"https://avatars.githubusercontent.com/u/16180225?v=3","gravatar_id":"","url":"https://api.github.com/users/ProtonLights","html_url":"https://github.com/ProtonLights","followers_url":"https://api.github.com/users/ProtonLights/followers","following_url":"https://api.github.com/users/ProtonLights/following{/other_user}","gists_url":"https://api.github.com/users/ProtonLights/gists{/gist_id}","starred_url":"https://api.github.com/users/ProtonLights/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ProtonLights/subscriptions","organizations_url":"https://api.github.com/users/ProtonLights/orgs","repos_url":"https://api.github.com/users/ProtonLights/repos","events_url":"https://api.github.com/users/ProtonLights/events{/privacy}","received_events_url":"https://api.github.com/users/ProtonLights/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ProtonLights/cli","description":"Command line interface to manipulate ProtonLights projects.","fork":false,"url":"https://api.github.com/repos/ProtonLights/cli","forks_url":"https://api.github.com/repos/ProtonLights/cli/forks","keys_url":"https://api.github.com/repos/ProtonLights/cli/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ProtonLights/cli/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ProtonLights/cli/teams","hooks_url":"https://api.github.com/repos/ProtonLights/cli/hooks","issue_events_url":"https://api.github.com/repos/ProtonLights/cli/issues/events{/number}","events_url":"https://api.github.com/repos/ProtonLights/cli/events","assignees_url":"https://api.github.com/repos/ProtonLights/cli/assignees{/user}","branches_url":"https://api.github.com/repos/ProtonLights/cli/branches{/branch}","tags_url":"https://api.github.com/repos/ProtonLights/cli/tags","blobs_url":"https://api.github.com/repos/ProtonLights/cli/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ProtonLights/cli/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ProtonLights/cli/git/refs{/sha}","trees_url":"https://api.github.com/repos/ProtonLights/cli/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ProtonLights/cli/statuses/{sha}","languages_url":"https://api.github.com/repos/ProtonLights/cli/languages","stargazers_url":"https://api.github.com/repos/ProtonLights/cli/stargazers","contributors_url":"https://api.github.com/repos/ProtonLights/cli/contributors","subscribers_url":"https://api.github.com/repos/ProtonLights/cli/subscribers","subscription_url":"https://api.github.com/repos/ProtonLights/cli/subscription","commits_url":"https://api.github.com/repos/ProtonLights/cli/commits{/sha}","git_commits_url":"https://api.github.com/repos/ProtonLights/cli/git/commits{/sha}","comments_url":"https://api.github.com/repos/ProtonLights/cli/comments{/number}","issue_comment_url":"https://api.github.com/repos/ProtonLights/cli/issues/comments{/number}","contents_url":"https://api.github.com/repos/ProtonLights/cli/contents/{+path}","compare_url":"https://api.github.com/repos/ProtonLights/cli/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ProtonLights/cli/merges","archive_url":"https://api.github.com/repos/ProtonLights/cli/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ProtonLights/cli/downloads","issues_url":"https://api.github.com/repos/ProtonLights/cli/issues{/number}","pulls_url":"https://api.github.com/repos/ProtonLights/cli/pulls{/number}","milestones_url":"https://api.github.com/repos/ProtonLights/cli/milestones{/number}","notifications_url":"https://api.github.com/repos/ProtonLights/cli/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ProtonLights/cli/labels{/name}","releases_url":"https://api.github.com/repos/ProtonLights/cli/releases{/id}","deployments_url":"https://api.github.com/repos/ProtonLights/cli/deployments","created_at":"2016-03-15T05:18:01Z","updated_at":"2016-03-23T03:21:31Z","pushed_at":"2016-07-08T02:22:10Z","git_url":"git://github.com/ProtonLights/cli.git","ssh_url":"git@github.com:ProtonLights/cli.git","clone_url":"https://github.com/ProtonLights/cli.git","svn_url":"https://github.com/ProtonLights/cli","homepage":null,"size":24616,"stargazers_count":1,"watchers_count":1,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":8,"forks":0,"open_issues":8,"watchers":1,"default_branch":"master"}},"base":{"label":"ProtonLights:master","ref":"master","sha":"cc8656a5dfd0748fcbb9b76daff1bf952b27006a","user":{"login":"ProtonLights","id":16180225,"avatar_url":"https://avatars.githubusercontent.com/u/16180225?v=3","gravatar_id":"","url":"https://api.github.com/users/ProtonLights","html_url":"https://github.com/ProtonLights","followers_url":"https://api.github.com/users/ProtonLights/followers","following_url":"https://api.github.com/users/ProtonLights/following{/other_user}","gists_url":"https://api.github.com/users/ProtonLights/gists{/gist_id}","starred_url":"https://api.github.com/users/ProtonLights/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ProtonLights/subscriptions","organizations_url":"https://api.github.com/users/ProtonLights/orgs","repos_url":"https://api.github.com/users/ProtonLights/repos","events_url":"https://api.github.com/users/ProtonLights/events{/privacy}","received_events_url":"https://api.github.com/users/ProtonLights/received_events","type":"Organization","site_admin":false},"repo":{"id":53916850,"name":"cli","full_name":"ProtonLights/cli","owner":{"login":"ProtonLights","id":16180225,"avatar_url":"https://avatars.githubusercontent.com/u/16180225?v=3","gravatar_id":"","url":"https://api.github.com/users/ProtonLights","html_url":"https://github.com/ProtonLights","followers_url":"https://api.github.com/users/ProtonLights/followers","following_url":"https://api.github.com/users/ProtonLights/following{/other_user}","gists_url":"https://api.github.com/users/ProtonLights/gists{/gist_id}","starred_url":"https://api.github.com/users/ProtonLights/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ProtonLights/subscriptions","organizations_url":"https://api.github.com/users/ProtonLights/orgs","repos_url":"https://api.github.com/users/ProtonLights/repos","events_url":"https://api.github.com/users/ProtonLights/events{/privacy}","received_events_url":"https://api.github.com/users/ProtonLights/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ProtonLights/cli","description":"Command line interface to manipulate ProtonLights projects.","fork":false,"url":"https://api.github.com/repos/ProtonLights/cli","forks_url":"https://api.github.com/repos/ProtonLights/cli/forks","keys_url":"https://api.github.com/repos/ProtonLights/cli/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ProtonLights/cli/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ProtonLights/cli/teams","hooks_url":"https://api.github.com/repos/ProtonLights/cli/hooks","issue_events_url":"https://api.github.com/repos/ProtonLights/cli/issues/events{/number}","events_url":"https://api.github.com/repos/ProtonLights/cli/events","assignees_url":"https://api.github.com/repos/ProtonLights/cli/assignees{/user}","branches_url":"https://api.github.com/repos/ProtonLights/cli/branches{/branch}","tags_url":"https://api.github.com/repos/ProtonLights/cli/tags","blobs_url":"https://api.github.com/repos/ProtonLights/cli/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ProtonLights/cli/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ProtonLights/cli/git/refs{/sha}","trees_url":"https://api.github.com/repos/ProtonLights/cli/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ProtonLights/cli/statuses/{sha}","languages_url":"https://api.github.com/repos/ProtonLights/cli/languages","stargazers_url":"https://api.github.com/repos/ProtonLights/cli/stargazers","contributors_url":"https://api.github.com/repos/ProtonLights/cli/contributors","subscribers_url":"https://api.github.com/repos/ProtonLights/cli/subscribers","subscription_url":"https://api.github.com/repos/ProtonLights/cli/subscription","commits_url":"https://api.github.com/repos/ProtonLights/cli/commits{/sha}","git_commits_url":"https://api.github.com/repos/ProtonLights/cli/git/commits{/sha}","comments_url":"https://api.github.com/repos/ProtonLights/cli/comments{/number}","issue_comment_url":"https://api.github.com/repos/ProtonLights/cli/issues/comments{/number}","contents_url":"https://api.github.com/repos/ProtonLights/cli/contents/{+path}","compare_url":"https://api.github.com/repos/ProtonLights/cli/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ProtonLights/cli/merges","archive_url":"https://api.github.com/repos/ProtonLights/cli/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ProtonLights/cli/downloads","issues_url":"https://api.github.com/repos/ProtonLights/cli/issues{/number}","pulls_url":"https://api.github.com/repos/ProtonLights/cli/pulls{/number}","milestones_url":"https://api.github.com/repos/ProtonLights/cli/milestones{/number}","notifications_url":"https://api.github.com/repos/ProtonLights/cli/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ProtonLights/cli/labels{/name}","releases_url":"https://api.github.com/repos/ProtonLights/cli/releases{/id}","deployments_url":"https://api.github.com/repos/ProtonLights/cli/deployments","created_at":"2016-03-15T05:18:01Z","updated_at":"2016-03-23T03:21:31Z","pushed_at":"2016-07-08T02:22:10Z","git_url":"git://github.com/ProtonLights/cli.git","ssh_url":"git@github.com:ProtonLights/cli.git","clone_url":"https://github.com/ProtonLights/cli.git","svn_url":"https://github.com/ProtonLights/cli","homepage":null,"size":24616,"stargazers_count":1,"watchers_count":1,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":8,"forks":0,"open_issues":8,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ProtonLights/cli/pulls/27"},"html":{"href":"https://github.com/ProtonLights/cli/pull/27"},"issue":{"href":"https://api.github.com/repos/ProtonLights/cli/issues/27"},"comments":{"href":"https://api.github.com/repos/ProtonLights/cli/issues/27/comments"},"review_comments":{"href":"https://api.github.com/repos/ProtonLights/cli/pulls/27/comments"},"review_comment":{"href":"https://api.github.com/repos/ProtonLights/cli/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ProtonLights/cli/pulls/27/commits"},"statuses":{"href":"https://api.github.com/repos/ProtonLights/cli/statuses/021569af45b8d66c617a56d66d19a4a6fcdbb336"}}}}
{"actor":{"display_login":"rjayatilleka"}}