diff --git a/app/Main.hs b/app/Main.hs
--- a/app/Main.hs
+++ b/app/Main.hs
@@ -1,7 +1,62 @@
+{-# OPTIONS_GHC -Wno-unused-imports -Wno-type-defaults -Wno-unused-top-binds #-}
 module Main where
 
+import Control.Applicative (Alternative(..))
+-- optparse
+import Options.Applicative (Parser, ParserInfo, customExecParser, prefs, showHelpOnEmpty, showHelpOnError, execParser, (<**>), helper, info, fullDesc, progDesc, header, strOption, option, auto, long, short, flag', value, showDefault, metavar)
+-- time
+import Data.Time.Calendar (Day, toGregorian, fromGregorian)
 
-import Text.Printf (printf)
+import API.JPL.Horizons (saveCsv, Body(..))
 
+
+
 main :: IO ()
-main = printf "hello"
+main = do
+  (Cfg d0 d1 r bdy) <- customExecParser (prefs showHelpOnError) opts
+  saveCsv (d0, d1) r bdy "data"
+
+
+opts :: ParserInfo Cfg
+opts = info (cfgP <**> helper)
+  ( fullDesc
+  <> progDesc "jpl-horizons-api"
+  <> header "jpl-horizons-api - download ephemerides in CSV format" )
+
+data Cfg = Cfg {
+  cfgDay0 :: Day
+  , cfgDay1 :: Day
+  , cfgResolnMin :: Int
+  , cfgBody :: Body 
+               }
+
+cfgP :: Parser Cfg
+cfgP = Cfg <$>
+       day0P <*>
+       day1P <*>
+       resolnP <*>
+       bodyP
+
+resolnP :: Parser Int
+resolnP = option auto (long "resolution" <>
+                       metavar "MINUTES" <>
+                      value 30 <>
+                      showDefault)
+
+day0P :: Parser Day
+day0P = fromGregorian <$>
+          option auto (long "year_start" <> metavar "YEAR") <*>
+          option auto (long "month_start" <> value 1 <> showDefault) <*>
+          option auto (long "day_start" <> value 1 <> showDefault)
+
+day1P :: Parser Day
+day1P = fromGregorian <$>
+          option auto (long "year_stop" <> metavar "YEAR") <*>
+          option auto (long "month_stop" <> value 1 <> showDefault) <*>
+          option auto (long "day_stop" <> value 1 <> showDefault)
+
+bodyP :: Parser Body
+bodyP = flag' Sun (long "sun") <|>
+        flag' Mercury (long "mercury") <|>
+        flag' Venus (long "venus") <|>
+        flag' Earth (long "earth")
diff --git a/jpl-horizons-api.cabal b/jpl-horizons-api.cabal
--- a/jpl-horizons-api.cabal
+++ b/jpl-horizons-api.cabal
@@ -1,12 +1,12 @@
 name:                jpl-horizons-api
-version:             0.2.0.0
+version:             0.3.0.0
 synopsis: Ephemerides for solar system objects from the JPL Horizons service
 description: The JPL Horizons on-line solar system data and ephemeris computation service provides access to key solar system data and flexible production of highly accurate ephemerides for solar system objects (1,180,796 asteroids, 3,789 comets, 211 planetary satellites {includes satellites of Earth and dwarf planet Pluto}, 8 planets, the Sun, L1, L2, select spacecraft, and system barycenters). Horizons is provided by the Solar System Dynamics Group of the Jet Propulsion Laboratory.
 homepage:            https://github.com/ocramz/jpl-horizons-api
 license:             BSD3
 license-file:        LICENSE
 author:              Marco Zocca
-maintainer:          example@example.com
+maintainer:          ocramz
 copyright:           2022 Marco Zocca
 category:            API, Astronomy
 build-type:          Simple
@@ -27,13 +27,15 @@
                      , text >= 1.2.4.1
                      , time
 
-executable jpl-horizons-api
+executable jh-csv
   default-language:    Haskell2010
   ghc-options:         -threaded -rtsopts -with-rtsopts=-N
   hs-source-dirs:      app
   main-is:             Main.hs
   build-depends:       base
                      , jpl-horizons-api
+                     , optparse-applicative
+                     , time
 
 -- test-suite spec
 --   default-language:    Haskell2010
