reups_lib/
completions.rs

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
4 * Copyright Nate Lust 2018*/
5
6use crate::argparse;
7use std::io;
8
9/**
10 * The completions subcommand invokes this function with the shell variable
11 * parsed from the command line. It is responsible for generating the
12 * corresponding shell completion scripts for the supplied shell.
13 *
14 * This generates bindings for the main reups application, and also bindings
15 * specifically for the rsetup subcommand.
16 *
17 * The resulting scripts are output to stdout so the user has the ability
18 * to pipe them to the appropriate location.
19 */
20pub fn write_completions_stdout(shell: &str) {
21    // Generate completions for the main reups program for all subcommands
22    argparse::build_cli().gen_completions_to("reups", shell.parse().unwrap(), &mut io::stdout());
23    // Generate conpletions for just the setup subcommand and bind these
24    // to the rsetup string. This lets auto completion work for the rsetup
25    // shell function
26    argparse::build_setup().gen_completions_to("rsetup", shell.parse().unwrap(), &mut io::stdout());
27}