{"action":"created","issue":{"url":"https://api.github.com/repos/acrisci/playerctl/issues/33","repository_url":"https://api.github.com/repos/acrisci/playerctl","labels_url":"https://api.github.com/repos/acrisci/playerctl/issues/33/labels{/name}","comments_url":"https://api.github.com/repos/acrisci/playerctl/issues/33/comments","events_url":"https://api.github.com/repos/acrisci/playerctl/issues/33/events","html_url":"https://github.com/acrisci/playerctl/pull/33","id":173657934,"number":33,"title":"Make the CLI client more robust","user":{"login":"Hjdskes","id":1260727,"avatar_url":"https://avatars.githubusercontent.com/u/1260727?v=3","gravatar_id":"","url":"https://api.github.com/users/Hjdskes","html_url":"https://github.com/Hjdskes","followers_url":"https://api.github.com/users/Hjdskes/followers","following_url":"https://api.github.com/users/Hjdskes/following{/other_user}","gists_url":"https://api.github.com/users/Hjdskes/gists{/gist_id}","starred_url":"https://api.github.com/users/Hjdskes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hjdskes/subscriptions","organizations_url":"https://api.github.com/users/Hjdskes/orgs","repos_url":"https://api.github.com/users/Hjdskes/repos","events_url":"https://api.github.com/users/Hjdskes/events{/privacy}","received_events_url":"https://api.github.com/users/Hjdskes/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-08-28T17:39:46Z","updated_at":"2016-09-29T15:26:43Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/acrisci/playerctl/pulls/33","html_url":"https://github.com/acrisci/playerctl/pull/33","diff_url":"https://github.com/acrisci/playerctl/pull/33.diff","patch_url":"https://github.com/acrisci/playerctl/pull/33.patch"},"body":"Hello again,\r\n\r\nAs promised in my previous PR, here are the changes I made to the CLI client. The intention is to fix some memory leaks, make it slightly more robust and improve its maintainability. By far the biggest change can be found in 7a98a0e9b42225107aebcdcde41cb0e39a894248, which greatly refactors the whole client. In a nutshell, I changed how the remaining command line arguments are handled:\r\n\r\nI introduced a new struct, `PlayerCommand`, abstracting the player commands. Per command, there is an instance of this struct containing its name and a function pointer to a function that processes the command. As before, all leftover command line arguments are passed into a string array (`**command`), which is now scanned by `parse_player_command`. The first matching command is executed.\r\n\r\nThese changes break the previously huge `main` function into smaller functions, one per command. Adding a new command is as simple as adding a new entry to the `PlayerCommand` array with a corresponding function. In my opinion, this greatly improves the maintainability and readability of the code.\r\n\r\nI have tested the functionality pretty extensively, and I think everything works as it should.  The user interface is untouched, e.g. all command line arguments and commands have the same name.\r\n\r\nThere are two improvements I'd like to make still, but I'd like your opinion on the current changes first so I'll probably do those once this PR is discussed.\r\n\r\n1. Enable stricter compiler checks, such as `-Wextra`, `-Wformat`, `-Wundef` and the like.\r\n2. Use compiler annotations to mark non-returning functions (`print_version_and_exit`, `list_all_players_and_exit`) and unused variables.\r\n3. `strtod` recognizes `+` and `-` when they prefix the number. Changing the command line syntax to `[+/-][VALUE]` for `volume` and `position` would give us positive and negative numbers for free, allowing us to drop the check for the last character and the multiplication with -1.\r\n\r\nThanks,\r\n\r\nJente\r\n"},"comment":{"url":"https://api.github.com/repos/acrisci/playerctl/issues/comments/250499806","html_url":"https://github.com/acrisci/playerctl/pull/33#issuecomment-250499806","issue_url":"https://api.github.com/repos/acrisci/playerctl/issues/33","id":250499806,"user":{"login":"Hjdskes","id":1260727,"avatar_url":"https://avatars.githubusercontent.com/u/1260727?v=3","gravatar_id":"","url":"https://api.github.com/users/Hjdskes","html_url":"https://github.com/Hjdskes","followers_url":"https://api.github.com/users/Hjdskes/followers","following_url":"https://api.github.com/users/Hjdskes/following{/other_user}","gists_url":"https://api.github.com/users/Hjdskes/gists{/gist_id}","starred_url":"https://api.github.com/users/Hjdskes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hjdskes/subscriptions","organizations_url":"https://api.github.com/users/Hjdskes/orgs","repos_url":"https://api.github.com/users/Hjdskes/repos","events_url":"https://api.github.com/users/Hjdskes/events{/privacy}","received_events_url":"https://api.github.com/users/Hjdskes/received_events","type":"User","site_admin":false},"created_at":"2016-09-29T15:26:43Z","updated_at":"2016-09-29T15:26:43Z","body":"Could you perhaps comment on the still open issues, so that I can get to work and finish this PR?"}}
{"actor":{"display_login":"Hjdskes"}}