From 090c8b4dd645d07b25163adab9b26fdf2b537a21 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Wed, 19 May 2010 23:06:46 +0000 Subject: [PATCH] move the hledger application modules to Hledger and Hledger.Cli --- Commands/All.hs | 67 --------- {Commands => Hledger/Cli/Commands}/Add.hs | 8 +- Hledger/Cli/Commands/All.hs | 67 +++++++++ {Commands => Hledger/Cli/Commands}/Balance.hs | 4 +- {Commands => Hledger/Cli/Commands}/Chart.hs | 4 +- {Commands => Hledger/Cli/Commands}/Convert.hs | 6 +- .../Cli/Commands}/Histogram.hs | 4 +- {Commands => Hledger/Cli/Commands}/Print.hs | 4 +- .../Cli/Commands}/Register.hs | 4 +- {Commands => Hledger/Cli/Commands}/Stats.hs | 4 +- {Commands => Hledger/Cli/Commands}/UI.hs | 10 +- {Commands => Hledger/Cli/Commands}/Web.hs | 16 +-- HledgerMain.hs => Hledger/Cli/Main.hs | 12 +- Options.hs => Hledger/Cli/Options.hs | 4 +- Tests.hs => Hledger/Tests.hs | 8 +- Utils.hs => Hledger/Utils.hs | 4 +- Version.hs => Hledger/Version.hs | 2 +- Makefile | 9 +- hledger.cabal | 133 +++++++++++++----- hledger.hs | 2 +- 20 files changed, 222 insertions(+), 150 deletions(-) delete mode 100644 Commands/All.hs rename {Commands => Hledger/Cli/Commands}/Add.hs (98%) create mode 100644 Hledger/Cli/Commands/All.hs rename {Commands => Hledger/Cli/Commands}/Balance.hs (98%) rename {Commands => Hledger/Cli/Commands}/Chart.hs (98%) rename {Commands => Hledger/Cli/Commands}/Convert.hs (99%) rename {Commands => Hledger/Cli/Commands}/Histogram.hs (96%) rename {Commands => Hledger/Cli/Commands}/Print.hs (92%) rename {Commands => Hledger/Cli/Commands}/Register.hs (99%) rename {Commands => Hledger/Cli/Commands}/Stats.hs (98%) rename {Commands => Hledger/Cli/Commands}/UI.hs (98%) rename {Commands => Hledger/Cli/Commands}/Web.hs (97%) rename HledgerMain.hs => Hledger/Cli/Main.hs (88%) rename Options.hs => Hledger/Cli/Options.hs (99%) rename Tests.hs => Hledger/Tests.hs (99%) rename Utils.hs => Hledger/Utils.hs (97%) rename Version.hs => Hledger/Version.hs (99%) diff --git a/Commands/All.hs b/Commands/All.hs deleted file mode 100644 index e7ffea0f0..000000000 --- a/Commands/All.hs +++ /dev/null @@ -1,67 +0,0 @@ -{-# LANGUAGE CPP #-} -{-| - -The Commands package defines all the commands offered by the hledger -application, like \"register\" and \"balance\". This module exports all -the commands; you can also import individual modules if you prefer. - --} - -module Commands.All ( - module Commands.Add, - module Commands.Balance, - module Commands.Convert, - module Commands.Histogram, - module Commands.Print, - module Commands.Register, - module Commands.Stats, -#ifdef VTY - module Commands.UI, -#endif -#if defined(WEB) || defined(WEBHAPPSTACK) - module Commands.Web, -#endif -#ifdef CHART - module Commands.Chart, -#endif - tests_Commands - ) -where -import Commands.Add -import Commands.Balance -import Commands.Convert -import Commands.Histogram -import Commands.Print -import Commands.Register -import Commands.Stats -#ifdef VTY -import Commands.UI -#endif -#if defined(WEB) || defined(WEBHAPPSTACK) -import Commands.Web -#endif -#ifdef CHART -import Commands.Chart -#endif -import Test.HUnit (Test(TestList)) - - -tests_Commands = TestList - [ --- Commands.Add.tests_Add --- ,Commands.Balance.tests_Balance - Commands.Convert.tests_Convert --- ,Commands.Histogram.tests_Histogram --- ,Commands.Print.tests_Print - ,Commands.Register.tests_Register --- ,Commands.Stats.tests_Stats - ] --- #ifdef VTY --- ,Commands.UI.tests_UI --- #endif --- #if defined(WEB) || defined(WEBHAPPSTACK) --- ,Commands.Web.tests_Web --- #endif --- #ifdef CHART --- ,Commands.Chart.tests_Chart --- #endif diff --git a/Commands/Add.hs b/Hledger/Cli/Commands/Add.hs similarity index 98% rename from Commands/Add.hs rename to Hledger/Cli/Commands/Add.hs index 7940a49b3..a509a8845 100644 --- a/Commands/Add.hs +++ b/Hledger/Cli/Commands/Add.hs @@ -5,11 +5,11 @@ A history-aware add command to help with data entry. -} -module Commands.Add +module Hledger.Cli.Commands.Add where import Ledger -import Options -import Commands.Register (showRegisterReport) +import Hledger.Cli.Options +import Hledger.Cli.Commands.Register (showRegisterReport) #if __GLASGOW_HASKELL__ <= 610 import Prelude hiding (putStr, putStrLn, getLine, appendFile) import System.IO.UTF8 @@ -19,7 +19,7 @@ import System.IO ( stderr, hFlush, hPutStrLn, hPutStr ) #endif import System.IO.Error import Text.ParserCombinators.Parsec -import Utils (ledgerFromStringWithOpts) +import Hledger.Utils (ledgerFromStringWithOpts) import qualified Data.Foldable as Foldable (find) -- | Read ledger transactions from the terminal, prompting for each field, diff --git a/Hledger/Cli/Commands/All.hs b/Hledger/Cli/Commands/All.hs new file mode 100644 index 000000000..9452c082c --- /dev/null +++ b/Hledger/Cli/Commands/All.hs @@ -0,0 +1,67 @@ +{-# LANGUAGE CPP #-} +{-| + +The Commands package defines all the commands offered by the hledger +application, like \"register\" and \"balance\". This module exports all +the commands; you can also import individual modules if you prefer. + +-} + +module Hledger.Cli.Commands.All ( + module Hledger.Cli.Commands.Add, + module Hledger.Cli.Commands.Balance, + module Hledger.Cli.Commands.Convert, + module Hledger.Cli.Commands.Histogram, + module Hledger.Cli.Commands.Print, + module Hledger.Cli.Commands.Register, + module Hledger.Cli.Commands.Stats, +#ifdef VTY + module Hledger.Cli.Commands.UI, +#endif +#if defined(WEB) || defined(WEBHAPPSTACK) + module Hledger.Cli.Commands.Web, +#endif +#ifdef CHART + module Hledger.Cli.Commands.Chart, +#endif + tests_Commands + ) +where +import Hledger.Cli.Commands.Add +import Hledger.Cli.Commands.Balance +import Hledger.Cli.Commands.Convert +import Hledger.Cli.Commands.Histogram +import Hledger.Cli.Commands.Print +import Hledger.Cli.Commands.Register +import Hledger.Cli.Commands.Stats +#ifdef VTY +import Hledger.Cli.Commands.UI +#endif +#if defined(WEB) || defined(WEBHAPPSTACK) +import Hledger.Cli.Commands.Web +#endif +#ifdef CHART +import Hledger.Cli.Commands.Chart +#endif +import Test.HUnit (Test(TestList)) + + +tests_Commands = TestList + [ +-- Hledger.Cli.Commands.Add.tests_Add +-- ,Hledger.Cli.Commands.Balance.tests_Balance + Hledger.Cli.Commands.Convert.tests_Convert +-- ,Hledger.Cli.Commands.Histogram.tests_Histogram +-- ,Hledger.Cli.Commands.Print.tests_Print + ,Hledger.Cli.Commands.Register.tests_Register +-- ,Hledger.Cli.Commands.Stats.tests_Stats + ] +-- #ifdef VTY +-- ,Hledger.Cli.Commands.UI.tests_UI +-- #endif +-- #if defined(WEB) || defined(WEBHAPPSTACK) +-- ,Hledger.Cli.Commands.Web.tests_Web +-- #endif +-- #ifdef CHART +-- ,Hledger.Cli.Commands.Chart.tests_Chart +-- #endif diff --git a/Commands/Balance.hs b/Hledger/Cli/Commands/Balance.hs similarity index 98% rename from Commands/Balance.hs rename to Hledger/Cli/Commands/Balance.hs index 40bef7ddd..039331b8c 100644 --- a/Commands/Balance.hs +++ b/Hledger/Cli/Commands/Balance.hs @@ -95,7 +95,7 @@ balance report: -} -module Commands.Balance +module Hledger.Cli.Commands.Balance where import Ledger.Utils import Ledger.Types @@ -103,7 +103,7 @@ import Ledger.Amount import Ledger.AccountName import Ledger.Posting import Ledger.Ledger -import Options +import Hledger.Cli.Options #if __GLASGOW_HASKELL__ <= 610 import Prelude hiding ( putStr ) import System.IO.UTF8 diff --git a/Commands/Chart.hs b/Hledger/Cli/Commands/Chart.hs similarity index 98% rename from Commands/Chart.hs rename to Hledger/Cli/Commands/Chart.hs index df7e8e215..71c552483 100644 --- a/Commands/Chart.hs +++ b/Hledger/Cli/Commands/Chart.hs @@ -4,14 +4,14 @@ Generate balances pie chart -} -module Commands.Chart +module Hledger.Cli.Commands.Chart where import Ledger.Utils import Ledger.Types import Ledger.Amount import Ledger.Ledger import Ledger.Commodity -import Options +import Hledger.Cli.Options import Control.Monad (liftM3) import Graphics.Rendering.Chart diff --git a/Commands/Convert.hs b/Hledger/Cli/Commands/Convert.hs similarity index 99% rename from Commands/Convert.hs rename to Hledger/Cli/Commands/Convert.hs index e4d77749e..322f8c289 100644 --- a/Commands/Convert.hs +++ b/Hledger/Cli/Commands/Convert.hs @@ -3,9 +3,9 @@ Convert account data in CSV format (eg downloaded from a bank) to ledger format, and print it on stdout. See the manual for more details. -} -module Commands.Convert where -import Options (Opt(Debug)) -import Version (versionstr) +module Hledger.Cli.Commands.Convert where +import Hledger.Cli.Options (Opt(Debug)) +import Hledger.Version (versionstr) import Ledger.Types (Ledger,AccountName,Transaction(..),Posting(..),PostingType(..)) import Ledger.Utils (strip, spacenonewline, restofline, parseWithCtx, assertParse, assertParseEqual) import Ledger.Parse (someamount, emptyCtx, ledgeraccountname) diff --git a/Commands/Histogram.hs b/Hledger/Cli/Commands/Histogram.hs similarity index 96% rename from Commands/Histogram.hs rename to Hledger/Cli/Commands/Histogram.hs index f4437e0c4..d1995e8db 100644 --- a/Commands/Histogram.hs +++ b/Hledger/Cli/Commands/Histogram.hs @@ -5,10 +5,10 @@ Print a histogram report. -} -module Commands.Histogram +module Hledger.Cli.Commands.Histogram where import Ledger -import Options +import Hledger.Cli.Options #if __GLASGOW_HASKELL__ <= 610 import Prelude hiding ( putStr ) import System.IO.UTF8 diff --git a/Commands/Print.hs b/Hledger/Cli/Commands/Print.hs similarity index 92% rename from Commands/Print.hs rename to Hledger/Cli/Commands/Print.hs index 31d28d3a2..19d85c708 100644 --- a/Commands/Print.hs +++ b/Hledger/Cli/Commands/Print.hs @@ -5,10 +5,10 @@ A ledger-compatible @print@ command. -} -module Commands.Print +module Hledger.Cli.Commands.Print where import Ledger -import Options +import Hledger.Cli.Options #if __GLASGOW_HASKELL__ <= 610 import Prelude hiding ( putStr ) import System.IO.UTF8 diff --git a/Commands/Register.hs b/Hledger/Cli/Commands/Register.hs similarity index 99% rename from Commands/Register.hs rename to Hledger/Cli/Commands/Register.hs index ac80f7d93..1353b659b 100644 --- a/Commands/Register.hs +++ b/Hledger/Cli/Commands/Register.hs @@ -5,7 +5,7 @@ A ledger-compatible @register@ command. -} -module Commands.Register ( +module Hledger.Cli.Commands.Register ( register ,showRegisterReport ,showPostingWithBalance @@ -14,7 +14,7 @@ module Commands.Register ( import Safe (headMay, lastMay) import Ledger -import Options +import Hledger.Cli.Options #if __GLASGOW_HASKELL__ <= 610 import Prelude hiding ( putStr ) import System.IO.UTF8 diff --git a/Commands/Stats.hs b/Hledger/Cli/Commands/Stats.hs similarity index 98% rename from Commands/Stats.hs rename to Hledger/Cli/Commands/Stats.hs index f19c2ab73..1af5b38c7 100644 --- a/Commands/Stats.hs +++ b/Hledger/Cli/Commands/Stats.hs @@ -5,10 +5,10 @@ Print some statistics for the ledger. -} -module Commands.Stats +module Hledger.Cli.Commands.Stats where import Ledger -import Options +import Hledger.Cli.Options #if __GLASGOW_HASKELL__ <= 610 import Prelude hiding ( putStr ) import System.IO.UTF8 diff --git a/Commands/UI.hs b/Hledger/Cli/Commands/UI.hs similarity index 98% rename from Commands/UI.hs rename to Hledger/Cli/Commands/UI.hs index d7a29b1e3..da9dea834 100644 --- a/Commands/UI.hs +++ b/Hledger/Cli/Commands/UI.hs @@ -4,15 +4,15 @@ A simple text UI for hledger, based on the vty library. -} -module Commands.UI +module Hledger.Cli.Commands.UI where import Safe (headDef) import Graphics.Vty import Ledger -import Options -import Commands.Balance -import Commands.Register -import Commands.Print +import Hledger.Cli.Options +import Hledger.Cli.Commands.Balance +import Hledger.Cli.Commands.Register +import Hledger.Cli.Commands.Print helpmsg = "(b)alance, (r)egister, (p)rint, (right) to drill down, (left) to back up, (q)uit" diff --git a/Commands/Web.hs b/Hledger/Cli/Commands/Web.hs similarity index 97% rename from Commands/Web.hs rename to Hledger/Cli/Commands/Web.hs index 6904ff378..f356d7f26 100644 --- a/Commands/Web.hs +++ b/Hledger/Cli/Commands/Web.hs @@ -4,7 +4,7 @@ A web-based UI. -} -module Commands.Web +module Hledger.Cli.Commands.Web where #if __GLASGOW_HASKELL__ <= 610 import Codec.Binary.UTF8.String (decodeString) @@ -39,19 +39,19 @@ import HSP hiding (Request,catch) import qualified HSP (Request(..)) import HSP.HTML (renderAsHTML) -import Commands.Add (ledgerAddTransaction) -import Commands.Balance -import Commands.Histogram -import Commands.Print -import Commands.Register +import Hledger.Cli.Commands.Add (ledgerAddTransaction) +import Hledger.Cli.Commands.Balance +import Hledger.Cli.Commands.Histogram +import Hledger.Cli.Commands.Print +import Hledger.Cli.Commands.Register import Ledger -import Options hiding (value) +import Hledger.Cli.Options hiding (value) #ifdef MAKE import Paths_hledger_make (getDataFileName) #else import Paths_hledger (getDataFileName) #endif -import Utils (openBrowserOn) +import Hledger.Utils (openBrowserOn) -- import Debug.Trace -- strace :: Show a => a -> a diff --git a/HledgerMain.hs b/Hledger/Cli/Main.hs similarity index 88% rename from HledgerMain.hs rename to Hledger/Cli/Main.hs index 6b3e09c72..55b062c44 100644 --- a/HledgerMain.hs +++ b/Hledger/Cli/Main.hs @@ -5,18 +5,18 @@ benchmark scripts. As a side benefit, this avoids a weakness of sp, which doesn't allow both #! and \{\-\# lines. -} -module HledgerMain where +module Hledger.Cli.Main where #if __GLASGOW_HASKELL__ <= 610 import Prelude hiding (putStr, putStrLn) import System.IO.UTF8 #endif -import Commands.All +import Hledger.Cli.Commands.All import Ledger -import Options -import Tests -import Utils (withLedgerDo) -import Version (versionmsg, binaryfilename) +import Hledger.Cli.Options +import Hledger.Tests +import Hledger.Utils (withLedgerDo) +import Hledger.Version (versionmsg, binaryfilename) main :: IO () main = do diff --git a/Options.hs b/Hledger/Cli/Options.hs similarity index 99% rename from Options.hs rename to Hledger/Cli/Options.hs index ece334795..ae68b4d24 100644 --- a/Options.hs +++ b/Hledger/Cli/Options.hs @@ -3,11 +3,11 @@ Command-line options for the application. -} -module Options +module Hledger.Cli.Options where import System.Console.GetOpt import System.Environment -import Version (timeprogname) +import Hledger.Version (timeprogname) import Ledger.IO (myLedgerPath,myTimelogPath) import Ledger.Utils import Ledger.Types diff --git a/Tests.hs b/Hledger/Tests.hs similarity index 99% rename from Tests.hs rename to Hledger/Tests.hs index 528e44b57..da11de457 100644 --- a/Tests.hs +++ b/Hledger/Tests.hs @@ -26,7 +26,7 @@ $ hledger -f sample.ledger balance o -} -module Tests +module Hledger.Tests where import qualified Data.Map as Map import Data.Time.Format @@ -35,10 +35,10 @@ import Test.HUnit.Tools (runVerboseTests) import System.Exit (exitFailure, exitWith, ExitCode(ExitSuccess)) -- base 3 compatible import System.Time (ClockTime(TOD)) -import Commands.All +import Hledger.Cli.Commands.All import Ledger -- including testing utils in Ledger.Utils -import Options -import Utils +import Hledger.Cli.Options +import Hledger.Utils -- | Run unit tests. diff --git a/Utils.hs b/Hledger/Utils.hs similarity index 97% rename from Utils.hs rename to Hledger/Utils.hs index b29bc977c..5c1a10084 100644 --- a/Utils.hs +++ b/Hledger/Utils.hs @@ -6,11 +6,11 @@ Utilities for top-level modules and ghci. See also "Ledger.IO" and -} -module Utils +module Hledger.Utils where import Control.Monad.Error import Ledger -import Options (Opt(..),ledgerFilePathFromOpts) -- ,optsToFilterSpec) +import Hledger.Cli.Options (Opt(..),ledgerFilePathFromOpts) -- ,optsToFilterSpec) import System.Directory (doesFileExist) import System.IO (stderr) #if __GLASGOW_HASKELL__ <= 610 diff --git a/Version.hs b/Hledger/Version.hs similarity index 99% rename from Version.hs rename to Hledger/Version.hs index cb88a13b6..51e12e480 100644 --- a/Version.hs +++ b/Hledger/Version.hs @@ -4,7 +4,7 @@ Version-related utilities. See the Makefile for details of our version numbering policy. -} -module Version +module Hledger.Version where import System.Info (os, arch) import Ledger.Utils diff --git a/Makefile b/Makefile index b028e8eb3..12487c9a2 100644 --- a/Makefile +++ b/Makefile @@ -31,8 +31,11 @@ MAIN=hledger.hs SOURCEFILES:= \ $(MAIN) \ [A-Z]*hs \ - Commands/[A-Z]*hs \ - hledger-lib/Ledger/[A-Z]*hs + Hledger/*hs \ + Hledger/Cli/*hs \ + Hledger/Cli/Commands/*hs \ + hledger-lib/*hs \ + hledger-lib/Ledger/*hs DOCFILES:=README README2 MANUAL NEWS CONTRIBUTORS SCREENSHOTS BINARYFILENAME=`runhaskell ./hledger.hs --binary-filename` PATCHLEVEL:=$(shell expr `darcs changes --count --from-tag=\\\\\.` - 1) @@ -457,8 +460,8 @@ VERSION3:=$(VERSION) endif # files which should be updated when the version changes VERSIONSENSITIVEFILES=\ - Version.hs \ hledger.cabal \ + Hledger/Version.hs \ hledger-lib/hledger-lib.cabal \ Version.hs: $(VERSIONFILE) diff --git a/hledger.cabal b/hledger.cabal index f05ee80a3..d756f4597 100644 --- a/hledger.cabal +++ b/hledger.cabal @@ -51,38 +51,23 @@ flag chart description: enable the pie chart generation default: False --- minimal library so cabal list and ghc-pkg list will show this package -library - exposed-modules: - Version --- Build-Depends: --- base >= 3 && < 5 --- ,containers --- ,directory --- ,filepath --- ,old-time --- ,parsec --- ,time --- ,utf8-string >= 0.3 --- ,HUnit - executable hledger main-is: hledger.hs other-modules: - HledgerMain - Options Paths_hledger - Tests - Utils - Version - Commands.Add - Commands.All - Commands.Balance - Commands.Convert - Commands.Histogram - Commands.Print - Commands.Register - Commands.Stats + Hledger.Tests + Hledger.Utils + Hledger.Version + Hledger.Cli.Main + Hledger.Cli.Options + Hledger.Cli.Commands.Add + Hledger.Cli.Commands.All + Hledger.Cli.Commands.Balance + Hledger.Cli.Commands.Convert + Hledger.Cli.Commands.Histogram + Hledger.Cli.Commands.Print + Hledger.Cli.Commands.Register + Hledger.Cli.Commands.Stats build-depends: hledger-lib == 0.9 ,HUnit @@ -107,13 +92,13 @@ executable hledger if flag(vty) cpp-options: -DVTY - other-modules:Commands.UI + other-modules:Hledger.Cli.Commands.UI build-depends: vty >= 4.0.0.1 if flag(web) cpp-options: -DWEB - other-modules:Commands.Web + other-modules:Hledger.Cli.Commands.Web build-depends: hsp ,hsx @@ -128,7 +113,7 @@ executable hledger if flag(webhappstack) cpp-options: -DWEBHAPPSTACK - other-modules:Commands.Web + other-modules:Hledger.Cli.Commands.Web build-depends: hsp ,hsx @@ -147,7 +132,91 @@ executable hledger if flag(chart) cpp-options: -DCHART - other-modules:Commands.Chart + other-modules:Hledger.Cli.Commands.Chart + build-depends: + Chart >= 0.11 + ,colour + +library + exposed-modules: + Hledger.Tests + Hledger.Utils + Hledger.Version + Hledger.Cli.Main + Hledger.Cli.Options + Hledger.Cli.Commands.Add + Hledger.Cli.Commands.All + Hledger.Cli.Commands.Balance + Hledger.Cli.Commands.Convert + Hledger.Cli.Commands.Histogram + Hledger.Cli.Commands.Print + Hledger.Cli.Commands.Register + Hledger.Cli.Commands.Stats + build-depends: + hledger-lib >= 0.10 + ,HUnit + ,base >= 3 && < 5 + ,containers + ,csv + ,directory + ,filepath + ,mtl + ,old-locale + ,old-time + ,parsec + ,process + ,regexpr >= 0.5.1 + ,safe >= 0.2 + ,testpack >= 1 && < 2 + ,time + ,utf8-string >= 0.3 + + -- should set patchlevel here as in Makefile + cpp-options: -DPATCHLEVEL=0 + + if flag(vty) + cpp-options: -DVTY + exposed-modules:Hledger.Cli.Commands.UI + build-depends: + vty >= 4.0.0.1 + + if flag(web) + cpp-options: -DWEB + exposed-modules:Hledger.Cli.Commands.Web + build-depends: + hsp + ,hsx + ,xhtml >= 3000.2 + ,loli + ,io-storage + ,hack-contrib + ,hack + ,hack-handler-simpleserver + ,HTTP >= 4000.0 + ,applicative-extras + + if flag(webhappstack) + cpp-options: -DWEBHAPPSTACK + exposed-modules:Hledger.Cli.Commands.Web + build-depends: + hsp + ,hsx + ,xhtml >= 3000.2 + ,loli + ,io-storage + ,hack-contrib + ,hack + ,hack-handler-happstack + ,happstack >= 0.3 + ,happstack-data >= 0.3 + ,happstack-server >= 0.3 + ,happstack-state >= 0.3 + ,HTTP >= 4000.0 + ,applicative-extras + + if flag(chart) + cpp-options: -DCHART + exposed-modules:Hledger.Cli.Commands.Chart build-depends: Chart >= 0.11 ,colour diff --git a/hledger.hs b/hledger.hs index 538d4c4d0..f25f4f2d7 100644 --- a/hledger.hs +++ b/hledger.hs @@ -36,4 +36,4 @@ See "Ledger.Ledger" for more examples. -} module Main where -import HledgerMain (main) +import Hledger.Cli.Main (main)