chip8-rust / chip8-ui

CHIP-8 graphical emulator built with the Rust programing language
MIT License
8 stars 0 forks source link

Use docopt.rs for argument parsing #26

Closed robo9k closed 9 years ago

robo9k commented 9 years ago

Right now the chip8_ui executable only supports one positional argument as the path of a ROM file. If no arguments are given, the intro is run instead.

I suggest using docopt/docopts.rs (Rust implementation of docopt) to implement more complex and self-documenting parsing of arguments:

CHIP-8 user interface.

Usage:
  chip8_ui intro
  chip8_ui run <rom>
  chip8_ui -h | --help
  chip8_ui -V | --version

Options:
  -h --help     Show this screen.
  -V --version  Show version.

This pattern is also expandable, e.g. one might add a --config=pong2.toml option and such lateron.

robo9k commented 9 years ago

The first version in 96973f2 does not implement the chip8_ui intro part. Upon further investigation, I do not think the intro warrants its own command. It could either be distributed as a separate file (intro.ch8) or if it should be built-in then it could be an addition, as in --with-intro or such (which might require implementing chip8_vm::instructions::Sys(0x42) or similar to return control).

jakerr commented 9 years ago

Yeah this sounds good to me.

I'm okay not having the intro open by default, in that case we should just make the rom parameter required. I'd like to continue to distribute the intro in an examples directory so that someone can try the app without going hunting for roms.

Thanks for doing this!