{"action":"created","issue":{"url":"https://api.github.com/repos/MRtrix3/mrtrix3/issues/334","labels_url":"https://api.github.com/repos/MRtrix3/mrtrix3/issues/334/labels{/name}","comments_url":"https://api.github.com/repos/MRtrix3/mrtrix3/issues/334/comments","events_url":"https://api.github.com/repos/MRtrix3/mrtrix3/issues/334/events","html_url":"https://github.com/MRtrix3/mrtrix3/issues/334","id":103738823,"number":334,"title":"get rid of default value specification in command-line parsing API?","user":{"login":"jdtournier","id":3221000,"avatar_url":"https://avatars.githubusercontent.com/u/3221000?v=3","gravatar_id":"","url":"https://api.github.com/users/jdtournier","html_url":"https://github.com/jdtournier","followers_url":"https://api.github.com/users/jdtournier/followers","following_url":"https://api.github.com/users/jdtournier/following{/other_user}","gists_url":"https://api.github.com/users/jdtournier/gists{/gist_id}","starred_url":"https://api.github.com/users/jdtournier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdtournier/subscriptions","organizations_url":"https://api.github.com/users/jdtournier/orgs","repos_url":"https://api.github.com/users/jdtournier/repos","events_url":"https://api.github.com/users/jdtournier/events{/privacy}","received_events_url":"https://api.github.com/users/jdtournier/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/MRtrix3/mrtrix3/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-08-28T15:23:13Z","updated_at":"2015-08-31T13:48:30Z","closed_at":null,"body":"At the moment, the `.type_integer()` & `.type_float()` methods take a default value, but this value is actually never used anywhere in the code - in fact, it's not even accessible in the API... \r\n\r\nIt was initially designed to be used to build a GUI for command-line only commands - the idea was to create an app that would run its target command with the `__print_full_usage__` argument, which causes the app to dump essentially all the information in the `usage()` function. The GUI app would then build a GUI from that information, and use the defaults provided to initialise fields where possible. The user would then fill out the information, press run, and the GUI app would invoke the command-line app. \r\n\r\nOnly problem is that I never got round to building the GUI part - and I'm not sure I'll ever do it. So unless someone else thinks this would be worthwhile, and wants to invest the time into this, maybe we should just remove those default values? Otherwise it's just confusing for new developers to be providing information that isn't used anywhere..."},"comment":{"url":"https://api.github.com/repos/MRtrix3/mrtrix3/issues/comments/136376724","html_url":"https://github.com/MRtrix3/mrtrix3/issues/334#issuecomment-136376724","issue_url":"https://api.github.com/repos/MRtrix3/mrtrix3/issues/334","id":136376724,"user":{"login":"dchristiaens","id":7466983,"avatar_url":"https://avatars.githubusercontent.com/u/7466983?v=3","gravatar_id":"","url":"https://api.github.com/users/dchristiaens","html_url":"https://github.com/dchristiaens","followers_url":"https://api.github.com/users/dchristiaens/followers","following_url":"https://api.github.com/users/dchristiaens/following{/other_user}","gists_url":"https://api.github.com/users/dchristiaens/gists{/gist_id}","starred_url":"https://api.github.com/users/dchristiaens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dchristiaens/subscriptions","organizations_url":"https://api.github.com/users/dchristiaens/orgs","repos_url":"https://api.github.com/users/dchristiaens/repos","events_url":"https://api.github.com/users/dchristiaens/events{/privacy}","received_events_url":"https://api.github.com/users/dchristiaens/received_events","type":"User","site_admin":false},"created_at":"2015-08-31T13:48:30Z","updated_at":"2015-08-31T13:48:30Z","body":"Sorry I'm a bit late to the party, but I would like to offer a counter-argument. I too have been annoyed at the non-use of the default arguments for a while. For example, my GT code is full of things like:\r\n```\r\n  + Option (\"t0\",\r\n            \"set the initial temperature of the metropolis hastings optimizer.\")\r\n    + Argument (\"start\").type_float(1e-6, 0.1, 1e6)\r\n\r\n// ...\r\n\r\n  double t0 = 0.1;\r\n  opt = get_options(\"t0\");\r\n  if (opt.size())\r\n    t0 = opt[0][0];\r\n```\r\nInstead of getting rid of unused defaults, why not actually _use_ them? Then, the example above could be reduced to:\r\n```\r\ndouble t0 = get_options(\"t0\")[0][0];\r\n```\r\nor even nicer (adding a function to the API):\r\n```\r\ndouble t0 = get_option_value(\"t0\");\r\n```\r\nI'm aware that this won't work for all options (e.g., there's no such thing as a _default_ response function, although...), but at least for those numeric parameters it could make life easier. It would avoid mistakingly specifying different defaults in the code and docs (or having to define macros for all defaults), and it would allow to set defaults for recurring options such as `lmax` MRtrix-wide instead of in each command separately.\r\n\r\nP.S.: Note that in the code above, the user still cannot look up the default without digging in the source code. This means that if I want to document default numeric values, I need to specify them a _third_ time as part of the text description of the option. If kept, it might be a good idea to include them in the docs as well."}}