<p>This is part one of the automatic bindings project.  I've taken all of the macros like <code>PARAM_STRING</code> and refactored them into <code>PARAM_STRING_IN</code> and <code>PARAM_STRING_OUT</code>, to denote which are input parameters and which are output parameters.  This information will be necessary when I am generating bindings to other languages.</p>

<p>I then had to go through all of the command-line programs and adapt the options.  In some cases, I had to change the name of parameters, but I preserved the old versions for reverse-compatibility (so there is some code we will be able to remove for mlpack 3.0.0).  Any input string parameters that are filenames must have names that end in <code>_file</code>.</p>

<p>Note that while there is, e.g., <code>PARAM_STRING_IN_REQ()</code> (a required input parameter), there is no <code>PARAM_STRING_OUT_REQ()</code> since I don't think it's reasonable to require that users handle their output.  That means that some programs, like <code>mlpack_preprocess_split</code> and others, have been changed to issue warnings instead of fatal errors when output parameters are not specified.</p>

<p>When there is an output parameter that does not end in <code>_file</code>, its value will be printed to stdout at the termination of the program.  Right now I think only <code>mlpack_hmm_loglik</code> uses a non-filename output parameter.</p>

<p>I've tested each of the command-line programs to ensure that they still function, and in some cases I've fixed a few bugs with them.</p>

<p><a href="https://github.com/keonkim" class="user-mention">@keonkim</a>: my work affects mlpack_preprocess_split and mlpack_preprocess_binarize more than trivially, so let me know if any of my changes are problematic.<br>
<a href="https://github.com/mentekid" class="user-mention">@mentekid</a>: when I merged <code>lsh_main.cpp</code> with multiprobe and recall computation support, the merge was imperfect.  I think I fixed everything, but can you take a quick look and make sure everything still works properly?<br>
<a href="https://github.com/zoq" class="user-mention">@zoq</a>: I could not get the <code>mlpack_rmva</code> program to run correctly ("<code>Target class out of range</code>"), but I couldn't get it to work before, either, so I don't know if my changes have broken anything.</p>

<p>The only reason all these checks are necessary is that we don't have a good infrastructure for testing command-line executables.  But, this change here is the first in a long set of steps to getting that infrastructure built.</p>

<p>(The next part of the plan, not included in this PR, is to change <code>PARAM_STRING_IN("input_file", "...", "i");</code> to <code>PARAM_MATRIX_IN("input", "...", "i");</code> and then the input matrix will be available directly with <code>CLI::GetParam&lt;arma::mat&gt;("input");</code>, and the help dialog will automatically display an entry for <code>--input_file</code>, so that the changes are transparent to the user.)</p>

<hr>

<h4>You can view, comment on, or merge this pull request online at:</h4>
<p>&nbsp;&nbsp;<a href='https://github.com/mlpack/mlpack/pull/723'>https://github.com/mlpack/mlpack/pull/723</a></p>

<h4>Commit Summary</h4>
<ul>
  <li>Refactor to support input and output parameters.</li>
  <li>Refactor programs to support input and output parameters.</li>
  <li>Merge branch &#39;master&#39; into bindings</li>
  <li>Fix duplicate options.</li>
  <li>Don&#39;t print extra lines.</li>
  <li>Warn when the user does not specify a file to test but asks for output.</li>
  <li>Fix misspelled parameter name.</li>
  <li>Fix parameter name issues.</li>
  <li>Better warnings when --output_file is not specified.</li>
  <li>Correct warning for no output.</li>
  <li>There is no such thing as a required output option.</li>
  <li>Update to --output_predictions_file, but keep old version for reverse compatibility.</li>
  <li>Only print output parameters that are strings and end with &quot;_file&quot;.</li>
  <li>Print any output options at the end of the run.</li>
  <li>Fix wrong conditional for printing warning.</li>
  <li>Add warning for kernel_pca when --output_file is not specified.</li>
  <li>Add reverse compatibility for some incorrectly-named parameters.</li>
</ul>

<h4>File Changes</h4>
<ul>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-0">src/mlpack/core/util/cli.cpp</a>
    (126)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-1">src/mlpack/core/util/cli.hpp</a>
    (351)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-2">src/mlpack/core/util/cli_impl.hpp</a>
    (20)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-3">src/mlpack/core/util/option.hpp</a>
    (8)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-4">src/mlpack/core/util/option_impl.hpp</a>
    (11)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-5">src/mlpack/core/util/param.hpp</a>
    (426)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-6">src/mlpack/methods/adaboost/adaboost_main.cpp</a>
    (37)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-7">src/mlpack/methods/cf/cf_main.cpp</a>
    (44)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-8">src/mlpack/methods/decision_stump/decision_stump_main.cpp</a>
    (23)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-9">src/mlpack/methods/det/det_main.cpp</a>
    (37)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-10">src/mlpack/methods/emst/emst_main.cpp</a>
    (20)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-11">src/mlpack/methods/fastmks/fastmks_main.cpp</a>
    (33)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-12">src/mlpack/methods/gmm/gmm_generate_main.cpp</a>
    (13)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-13">src/mlpack/methods/gmm/gmm_probability_main.cpp</a>
    (19)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-14">src/mlpack/methods/gmm/gmm_train_main.cpp</a>
    (26)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-15">src/mlpack/methods/hmm/hmm_generate_main.cpp</a>
    (23)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-16">src/mlpack/methods/hmm/hmm_loglik_main.cpp</a>
    (8)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-17">src/mlpack/methods/hmm/hmm_train_main.cpp</a>
    (21)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-18">src/mlpack/methods/hmm/hmm_viterbi_main.cpp</a>
    (10)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-19">src/mlpack/methods/hoeffding_trees/hoeffding_tree_main.cpp</a>
    (36)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-20">src/mlpack/methods/kernel_pca/kernel_pca_main.cpp</a>
    (31)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-21">src/mlpack/methods/kmeans/kmeans_main.cpp</a>
    (37)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-22">src/mlpack/methods/lars/lars_main.cpp</a>
    (61)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-23">src/mlpack/methods/linear_regression/linear_regression_main.cpp</a>
    (63)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-24">src/mlpack/methods/local_coordinate_coding/local_coordinate_coding_main.cpp</a>
    (32)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-25">src/mlpack/methods/logistic_regression/logistic_regression_main.cpp</a>
    (48)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-26">src/mlpack/methods/lsh/lsh_main.cpp</a>
    (49)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-27">src/mlpack/methods/mean_shift/mean_shift_main.cpp</a>
    (80)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-28">src/mlpack/methods/mvu/mvu_main.cpp</a>
    (8)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-29">src/mlpack/methods/naive_bayes/nbc_main.cpp</a>
    (17)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-30">src/mlpack/methods/nca/nca_main.cpp</a>
    (49)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-31">src/mlpack/methods/neighbor_search/kfn_main.cpp</a>
    (42)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-32">src/mlpack/methods/neighbor_search/knn_main.cpp</a>
    (29)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-33">src/mlpack/methods/nmf/nmf_main.cpp</a>
    (36)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-34">src/mlpack/methods/pca/pca_main.cpp</a>
    (27)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-35">src/mlpack/methods/perceptron/perceptron_main.cpp</a>
    (34)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-36">src/mlpack/methods/preprocess/preprocess_binarize_main.cpp</a>
    (18)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-37">src/mlpack/methods/preprocess/preprocess_split_main.cpp</a>
    (64)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-38">src/mlpack/methods/radical/radical_main.cpp</a>
    (65)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-39">src/mlpack/methods/range_search/range_search_main.cpp</a>
    (27)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-40">src/mlpack/methods/rann/krann_main.cpp</a>
    (31)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-41">src/mlpack/methods/rmva/rmva_main.cpp</a>
    (37)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-42">src/mlpack/methods/softmax_regression/softmax_regression_main.cpp</a>
    (35)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-43">src/mlpack/methods/sparse_coding/sparse_coding_main.cpp</a>
    (56)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/723/files#diff-44">src/mlpack/tests/cli_test.cpp</a>
    (2)
  </li>
</ul>

<h4>Patch Links:</h4>
<ul>
  <li><a href='https://github.com/mlpack/mlpack/pull/723.patch'>https://github.com/mlpack/mlpack/pull/723.patch</a></li>
  <li><a href='https://github.com/mlpack/mlpack/pull/723.diff'>https://github.com/mlpack/mlpack/pull/723.diff</a></li>
</ul>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">&mdash;<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/mlpack/mlpack/pull/723">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AJ4bFOn4WMYrBjg7lQdfzPYmskU57h5Uks5qV6zBgaJpZM4JNibO">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFHcHIkt1qk4QEm2QgMXhVdfL9W21ks5qV6zBgaJpZM4JNibO.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/mlpack/mlpack/pull/723"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>