Structure of my structs

I'm writing a command line tool that lets you select custom commands by pressing a single key. In it, my structs are structured like this:

  • RawStdout has fields and methods for a RawTerminal<std::io::Stdout>.

  • Screen has methods that write data to RawStdout.

  • Step groups methods from Screen (and other structs like Input, CmdRunner, etc.) into steps, which are actually methods: show_menu, get_input, etc.

  • My integration tests (I'm not sure if they are integration tests) test Step's methods: show_menu, get_input, etc.

Is this a reasonable structure for my structs? Any comments or suggestions?

Note: I posted this question on a reddit group, but I didn't get many replies.

Sounds like you're reinventing tools like GitHub - denisidoro/navi: An interactive cheatsheet tool for the command-line

1 Like

Yeah, that's very similar to my command-line tool. Is it possible to run commands by pressing only one key? The main reason I created my command-line tool was to be able to do this:

  1. k + Enter (the command line tool has started)
  2. c (the command mapped to c is running now)

And avoid a fuzzy search.

It would be useful it you could share some code, otherwise it's hard to do a code review.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.