Skip to content

Commit

Permalink
cli: util: don't use formatter to print raw data
Browse files Browse the repository at this point in the history
I don't think escape sequences in those contents should be escaped depending
on the output device.
  • Loading branch information
yuja committed Nov 4, 2024
1 parent 8f9d1a9 commit 987bb5e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion cli/src/commands/util/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use std::io::Write as _;

use clap::Command;

use crate::cli_util::CommandHelper;
Expand Down Expand Up @@ -96,7 +98,7 @@ pub fn cmd_util_completion(
};

let buf = shell.generate(&mut app);
ui.stdout_formatter().write_all(&buf)?;
ui.stdout().write_all(&buf)?;
Ok(())
}

Expand Down
4 changes: 3 additions & 1 deletion cli/src/commands/util/config_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use std::io::Write as _;

use crate::cli_util::CommandHelper;
use crate::command_error::CommandError;
use crate::ui::Ui;
Expand All @@ -27,6 +29,6 @@ pub fn cmd_util_config_schema(
) -> Result<(), CommandError> {
// TODO(#879): Consider generating entire schema dynamically vs. static file.
let buf = include_bytes!("../../config-schema.json");
ui.stdout_formatter().write_all(buf)?;
ui.stdout().write_all(buf)?;
Ok(())
}
4 changes: 3 additions & 1 deletion cli/src/commands/util/mangen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use std::io::Write as _;

use crate::cli_util::CommandHelper;
use crate::command_error::CommandError;
use crate::ui::Ui;
Expand All @@ -28,6 +30,6 @@ pub fn cmd_util_mangen(
let mut buf = vec![];
let man = clap_mangen::Man::new(command.app().clone());
man.render(&mut buf)?;
ui.stdout_formatter().write_all(&buf)?;
ui.stdout().write_all(&buf)?;
Ok(())
}
4 changes: 3 additions & 1 deletion cli/src/commands/util/markdown_help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use std::io::Write as _;

use crate::cli_util::CommandHelper;
use crate::command_error::CommandError;
use crate::ui::Ui;
Expand All @@ -28,6 +30,6 @@ pub fn cmd_util_markdown_help(
// If we ever need more flexibility, the code of `clap_markdown` is simple and
// readable. We could reimplement the parts we need without trouble.
let markdown = clap_markdown::help_markdown_command(command.app()).into_bytes();
ui.stdout_formatter().write_all(&markdown)?;
ui.stdout().write_all(&markdown)?;
Ok(())
}

0 comments on commit 987bb5e

Please sign in to comment.