{"action":"opened","issue":{"url":"https://api.github.com/repos/trevorld/r-argparse/issues/27","repository_url":"https://api.github.com/repos/trevorld/r-argparse","labels_url":"https://api.github.com/repos/trevorld/r-argparse/issues/27/labels{/name}","comments_url":"https://api.github.com/repos/trevorld/r-argparse/issues/27/comments","events_url":"https://api.github.com/repos/trevorld/r-argparse/issues/27/events","html_url":"https://github.com/trevorld/r-argparse/issues/27","id":389954217,"node_id":"MDU6SXNzdWUzODk5NTQyMTc=","number":27,"title":"Allow use of add_help argument in ArgumentParser creation","user":{"login":"chlige","id":4840583,"node_id":"MDQ6VXNlcjQ4NDA1ODM=","avatar_url":"https://avatars3.githubusercontent.com/u/4840583?v=4","gravatar_id":"","url":"https://api.github.com/users/chlige","html_url":"https://github.com/chlige","followers_url":"https://api.github.com/users/chlige/followers","following_url":"https://api.github.com/users/chlige/following{/other_user}","gists_url":"https://api.github.com/users/chlige/gists{/gist_id}","starred_url":"https://api.github.com/users/chlige/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chlige/subscriptions","organizations_url":"https://api.github.com/users/chlige/orgs","repos_url":"https://api.github.com/users/chlige/repos","events_url":"https://api.github.com/users/chlige/events{/privacy}","received_events_url":"https://api.github.com/users/chlige/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-12-11T21:08:05Z","updated_at":"2018-12-11T21:08:05Z","closed_at":null,"author_association":"NONE","body":"If the add_help argument is added in the ArgumentParser creation statement it is not properly translated into a Python boolean.  Currently it is converted into a string.  The following patch would properly convert an R boolean into a python boolean.  I grant the main developer a non-exclusive\r\nunlimited license for the code in this patch.\r\n\r\n`diff --git a/R/argparse.R b/R/argparse.R\r\nindex 3702090..3fab515 100644\r\n--- a/R/argparse.R\r\n+++ b/R/argparse.R\r\n@@ -292,6 +292,12 @@ convert_..._to_arguments <- function(mode, ...) {\r\n         formatter_class <- argument_list[[ii]]\r\n         proposed_arguments[ii] <- sprintf(\"formatter_class=%s\", formatter_class)\r\n     }\r\n+    # If add_help, convert to Python boolean\r\n+    if(mode == \"ArgumentParser\" && any(grepl(\"add_help=\", proposed_arguments))) {\r\n+        ii <- grep(\"add_help=\", proposed_arguments)\r\n+        add_help <- argument_list[[ii]]\r\n+        proposed_arguments[ii] <- sprintf(\"add_help=%s\", ifelse(add_help, 'True', 'False'))\r\n+    }\r\n     # Set right default prog name if not specified, if possible\r\n     # Do last to not screw up other fixes with prog insertion\r\n     if(mode == \"ArgumentParser\" && all(!grepl(\"prog=\", proposed_arguments))) {\r\n`"}}
{"actor":{"display_login":"chlige"}}