diff --git a/README.md b/README.md
--- a/README.md
+++ b/README.md
@@ -93,15 +93,22 @@
   pure $ map (\s -> testCase s $ pure ()) inputs
 ```
 
-## Support for additional ingredients
+## Configuration options
 
 You can add tasty ingredients with the `-optF` option:
 
 ``` haskell
 -- test/test.hs
-{-# OPTIONS_GHC -F -pgmF tasty-auto -optF Test.Tasty.Runners.Html.htmlRunner -optF Test.Tasty.Runners.AntXML.antXMLRunner #-}
+{-# OPTIONS_GHC -F -pgmF tasty-auto -optF --ingredient=Test.Tasty.Runners.Html.htmlRunner -optF --ingredient=Test.Tasty.Runners.AntXML.antXMLRunner #-}
 ```
 
+It is possible to configure the name of the generated module, if you want to import the module somewhere.
+
+``` haskell
+-- test/AutoTests.hs
+{-# OPTIONS_GHC -F -pgmF tasty-auto -optF --module=AutoTests #-}
+```
+
 ## Generated code
 
 The generated code of the preprocessor looks like this:
@@ -109,9 +116,10 @@
 ``` haskell
 {-# LINE 1 "test/test.hs" #-}
 {-# LANGUAGE FlexibleInstances #-}
-module Main where
+module Main (main, ingredients, tests) where
 import Prelude
 import qualified Test.Tasty as T
+import qualified Test.Tasty.Ingredients as T
 import qualified Test.Tasty.HUnit as HU
 import qualified Test.Tasty.QuickCheck as QC
 import qualified Test.Tasty.SmallCheck as SC
@@ -131,8 +139,8 @@
 instance TestGroup [T.TestTree]      where testGroup n a = pure $ T.testGroup n a
 instance TestGroup (IO T.TestTree)   where testGroup _ a = a
 instance TestGroup (IO [T.TestTree]) where testGroup n a = T.testGroup n <$> a
-main :: IO ()
-main = do
+tests :: IO T.TestTree
+tests = do
   t0 <- testCase "List comparison with different length" CaseTest.case_List_comparison_with_different_length
   t1 <- pure $ SC.testProperty "sort reverse" SCPropTest.scprop_sort_reverse
   t2 <- testGroup "Addition" TreeTest.test_Addition
@@ -142,5 +150,9 @@
   t6 <- pure $ QC.testProperty "Addition is commutative" PropTest.prop_Addition_is_commutative
   t7 <- HS.testSpec "Prelude" TestSpec.spec_Prelude
   t8 <- pure $ QC.testProperty "Addition is associative" SubMod.PropTest.prop_Addition_is_associative
-  T.defaultMain $ T.testGroup "test/test.hs" [t0,t1,t2,t3,t4,t5,t6,t7,t8]
+  pure $ T.testGroup "test/test.hs" [t0,t1,t2,t3,t4,t5,t6,t7,t8]
+ingredients :: [T.Ingredient]
+ingredients = T.defaultIngredients
+main :: IO ()
+main = tests >>= T.defaultMainWithIngredients ingredients
 ```
diff --git a/src/Test/Tasty/Auto.hs b/src/Test/Tasty/Auto.hs
--- a/src/Test/Tasty/Auto.hs
+++ b/src/Test/Tasty/Auto.hs
@@ -1,7 +1,7 @@
 module Test.Tasty.Auto (findTests, showTestDriver) where
 
 import Data.Function (on)
-import Data.List (find, isPrefixOf, isSuffixOf, nub, intersperse, groupBy, sortOn)
+import Data.List (find, isPrefixOf, isSuffixOf, nub, intersperse, groupBy, sortOn, dropWhileEnd)
 import Data.Maybe (fromJust)
 import System.Directory (getDirectoryContents, doesDirectoryExist)
 import Data.Traversable (for)
@@ -79,29 +79,33 @@
 foldEndo = appEndo . fold . fmap Endo
 
 ingredientImport :: String -> String
-ingredientImport = reverse . tail . dropWhile (/= '.') . reverse
+ingredientImport = init . dropWhileEnd (/= '.')
 
-mainFunction :: [String] -> ShowS
-mainFunction [] = str "  T.defaultMain"
-mainFunction ingredients = str "  T.defaultMainWithIngredients ("
-  . foldEndo (map (\i -> str i . (':':)) ingredients) . str "T.defaultIngredients)"
+ingredients :: [String] -> ShowS
+ingredients is = foldEndo (map (\i -> str i . (':':)) is) . str "T.defaultIngredients"
 
-showTestDriver :: [String] -> FilePath -> [Test] -> ShowS
-showTestDriver ingredients src ts = let gs = getGenerators ts; vars = map (str . ('t':) . show) [(0::Int)..] in
+showTestDriver :: String -> [String] -> FilePath -> [Test] -> ShowS
+showTestDriver modname is src ts =
+  let gs = getGenerators ts; vars = map (str . ('t':) . show) [(0::Int)..] in
     str "{-# LINE 1 " . shows src . str " #-}\n\
         \{-# LANGUAGE FlexibleInstances #-}\n\
-        \module Main where\n\
+        \module " . str modname . str " (main, ingredients, tests) where\n\
         \import Prelude\n\
-        \import qualified Test.Tasty as T\n"
+        \import qualified Test.Tasty as T\n\
+        \import qualified Test.Tasty.Ingredients as T\n"
   . foldEndo (map genImport gs)
-  . showImports (map ingredientImport ingredients ++ map testModule ts)
+  . showImports (map ingredientImport is ++ map testModule ts)
   . foldEndo (map genClass gs)
-  . str "main :: IO ()\n\
-        \main = do\n"
+  . str "tests :: IO T.TestTree\n\
+        \tests = do\n"
   . foldEndo (zipWith showSetup ts vars)
-  . mainFunction ingredients . str " $ T.testGroup " . shows src . str " ["
+  . str "  pure $ T.testGroup " . shows src . str " ["
   . foldEndo (intersperse (',':) $ zipWith (curry snd) ts vars)
   . str "]\n"
+  . str "ingredients :: [T.Ingredient]\n\
+        \ingredients = " . ingredients is . str "\n\
+        \main :: IO ()\n\
+        \main = tests >>= T.defaultMainWithIngredients ingredients\n"
 
 filesBySuffix :: FilePath -> [String] -> IO [FilePath]
 filesBySuffix dir suffixes = do
diff --git a/tasty-auto.cabal b/tasty-auto.cabal
--- a/tasty-auto.cabal
+++ b/tasty-auto.cabal
@@ -3,7 +3,7 @@
 -- see: https://github.com/sol/hpack
 
 name:           tasty-auto
-version:        0.1.0.2
+version:        0.2.0.0
 synopsis:       Auto discovery for Tasty with support for ingredients and test tree generation
 description:    Auto discovery for Tasty with support for ingredients and test tree generation
 category:       Testing
diff --git a/tasty-auto.hs b/tasty-auto.hs
--- a/tasty-auto.hs
+++ b/tasty-auto.hs
@@ -1,15 +1,29 @@
-import System.Exit (exitFailure)
+import Control.Monad (when)
+import Data.List (foldl')
+import System.Console.GetOpt (getOpt, usageInfo, ArgDescr(..), ArgOrder(..), OptDescr(..))
 import System.Environment (getArgs)
+import System.Exit (exitFailure)
 import System.IO (hPutStrLn, stderr)
 import Test.Tasty.Auto
 
+options :: [OptDescr ((String, [String], Bool) -> (String, [String], Bool))]
+options =
+  [ Option [] ["module"]     (ReqArg (\x (_, b, c) -> (x, b, c))        "MODULE")     "Qualified module name"
+  , Option [] ["ingredient"] (ReqArg (\x (a, b, c) -> (a, b ++ [x], c)) "INGREDIENT") "Qualified ingredient name"
+  , Option [] ["debug"]      (NoArg  (\   (a, b, _) -> (a, b, True)))                 "Debug output"
+  ]
+
 main :: IO ()
 main = do
   args <- getArgs
   case args of
-    src : _ : dst : ingredients -> do
-      tests <- findTests src
-      writeFile dst $ showTestDriver ingredients src tests ""
+    src : _ : dst : optargs
+      | (opts, [], []) <- getOpt Permute options optargs -> do
+          tests <- findTests src
+          let output = showTestDriver modname ingredients src tests ""
+              (modname, ingredients, debug) = foldl' (flip id) ("Main", [], False) opts
+          when debug $ hPutStrLn stderr output
+          writeFile dst output
     _ -> do
-      hPutStrLn stderr "tasty-auto: Expected source and destination arguments"
+      hPutStrLn stderr $ usageInfo "Usage: tasty-auto src _ dst [OPTION...]" options
       exitFailure
diff --git a/test/test.hs b/test/test.hs
--- a/test/test.hs
+++ b/test/test.hs
@@ -1,1 +1,1 @@
-{-# OPTIONS_GHC -F -pgmF tasty-auto #-}
+{-# OPTIONS_GHC -F -pgmF tasty-auto -optF --debug #-}
