# Option Parser with short flags

**URL:** <https://forum.crystal-lang.org/t/option-parser-with-short-flags/3578>\
**Category:** Help & Support\
**Created:** [August 1, 2021, 3:07pm UTC](https://forum.crystal-lang.org/t/option-parser-with-short-flags/3578 "2021-08-01T15:07:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kmf](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/kmf/32/1343_2.png) [@kmf](https://forum.crystal-lang.org/u/kmf)\
**Post date:** [August 1, 2021, 3:07pm UTC](https://forum.crystal-lang.org/t/option-parser-with-short-flags/3578/1 "2021-08-01T15:07:13Z")

</div>

Here is some test code with Option Parser,  
it doesn’t seem to work as expected … is it a bug, or am I using it wrong,  
the flags I need to use in my app it things like controls and compliance, so short flags are `con` or `com`  
each time I use the `long flags` in this example, they give an error, guidance will be appreciated

```auto
require "option_parser"
OptionParser.parse do |parser|
  parser.banner = "Usage: crunch [arguments]"

  parser.on("-spo", "--spoon", "Prints out spoon") { puts "spoon" }
  parser.on("-spa", "--spanner", "Prints out spanner") { puts "spanner" }
  parser.on("-h", "--help", "Show this help") do
    puts parser
    exit
  end
end

```

---

<div class="post-metadata">

**Author:** ![Blacksmoke16](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/blacksmoke16/32/1241_2.png) [@Blacksmoke16](https://forum.crystal-lang.org/u/Blacksmoke16)\
**Post date:** [August 1, 2021, 4:04pm UTC](https://forum.crystal-lang.org/t/option-parser-with-short-flags/3578/2 "2021-08-01T16:04:45Z")

</div>

I think it would make sense for the option parser to forbid the short argument from having more than 1 character as by convention that’s how long they should be. Otherwise there is no way to differentiate between your `-spo` option versus `-s -p -o` (which the option parser does not support either atm tho).

EDIT: [OptionParser support for stacked options · Issue #10981 · crystal-lang/crystal · GitHub](https://github.com/crystal-lang/crystal/issues/10981)
