# Parse conf file for CLI tool

**URL:** <https://www.ruby-forum.com/t/parse-conf-file-for-cli-tool/83494>\
**Category:** Ruby\
**Created:** [January 26, 2007, 5:32pm UTC](https://www.ruby-forum.com/t/parse-conf-file-for-cli-tool/83494 "2007-01-26T17:32:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![crytyca](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/3be4f8/32.png) [@crytyca](https://www.ruby-forum.com/u/crytyca)\
**Post date:** [January 26, 2007, 5:32pm UTC](https://www.ruby-forum.com/t/parse-conf-file-for-cli-tool/83494/1 "2007-01-26T17:32:30Z")

</div>

Hi,

I’m pretty new to ruby and want to program some some linux shell tools  
in ruby as exercise. For these tools I want to be able to specify  
options as parameters on the command line or in a config file.  
I already discovered OptionParser to parse the command line options.

Can someone give me suggestions which classes to look at to simplify the  
task of parsing a configuration file for options?

Regards,  
mo

---

<div class="post-metadata">

**Author:** ![crytyca](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/3be4f8/32.png) [@crytyca](https://www.ruby-forum.com/u/crytyca)\
**Post date:** [January 26, 2007, 5:46pm UTC](https://www.ruby-forum.com/t/parse-conf-file-for-cli-tool/83494/2 "2007-01-26T17:46:01Z")

</div>

On Sat, 27 Jan 2007, Moritz R. wrote:

> Regards,  
> mo

harp:~ \> cat a.rb  
#! /usr/bin/env ruby  
require ‘yaml’

config = ‘config.yml’  
options = YAML.load(IO.read(config))  
y options

## harp:~ \> cat config.yml

key : value  
a : b

harp:~ \> ruby a.rb  
a: b  
key: value

-a

---

<div class="post-metadata">

**Author:** ![crytyca](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/3be4f8/32.png) [@crytyca](https://www.ruby-forum.com/u/crytyca)\
**Post date:** [January 28, 2007, 4:43pm UTC](https://www.ruby-forum.com/t/parse-conf-file-for-cli-tool/83494/3 "2007-01-28T16:43:14Z")

</div>

That’s exactly what I was looking for. Thanks!
