Commits

Colin Woodbury committed 50d75bf

`-Ai` now shows dependencies - closes #148

  • Participants
  • Parent commits a258b93

Comments (0)

Files changed (3)

File Aura/Commands/A.hs

     , displayPkgbuild ) where
 
 import Text.Regex.PCRE ((=~))
+import Data.Maybe      (fromJust)
 import Control.Monad
 import Data.Monoid
 import qualified Data.Set as S (member, fromList)
 import           Aura.Install (InstallOptions(..))
 import qualified Aura.Install as I
 
+import Aura.Pkgbuild.Base
 import Aura.Settings.Base
 import Aura.Packages.ABS (absDepsRepo)
 import Aura.Packages.AUR
 import Aura.Monad.Aura
 import Aura.Languages
 import Aura.Utils
+import Aura.Bash (namespace, Namespace)
 import Aura.Core
 
 import Shell
 aurPkgInfo :: [String] -> Aura ()
 aurPkgInfo pkgs = aurInfoLookup pkgs >>= mapM_ displayAurPkgInfo
 
+-- By this point, the Package definitely exists, so we can assume its
+-- PKGBUILD exists on the AUR servers as well.
 displayAurPkgInfo :: PkgInfo -> Aura ()
-displayAurPkgInfo info = ask >>= \ss ->
-    liftIO $ putStrLn $ renderAurPkgInfo ss info ++ "\n"
-
-renderAurPkgInfo :: Settings -> PkgInfo -> String
-renderAurPkgInfo ss info = entrify ss fields entries
-    where fields  = map bForeground . infoFields . langOf $ ss
+displayAurPkgInfo info = ask >>= \ss -> do
+    let name = nameOf info
+    ns <- fromJust <$> downloadPkgbuild name >>= namespace name
+    liftIO $ putStrLn $ renderAurPkgInfo ss info ns ++ "\n"
+
+renderAurPkgInfo :: Settings -> PkgInfo -> Namespace -> String
+renderAurPkgInfo ss info ns = entrify ss fields entries
+    where fields   = map bForeground . infoFields . langOf $ ss
+          empty x  = case x of [] -> "None"; _ -> x
           entries = [ magenta "aur"
                     , bForeground $ nameOf info
                     , latestVerOf info
                     , cyan $ projectURLOf info
                     , aurURLOf info
                     , licenseOf info
+                    , empty . unwords . depends $ ns
+                    , empty . unwords . makedepends $ ns
                     , yellow . show . votesOf $ info
                     , descriptionOf info ]
 

File Aura/Languages.hs

 
 -- `Maintainer` value NEEDS UPDATING!
 infoFields :: Language -> [String]
-infoFields English    = [ "Repository","Name","Version","AUR Status","Maintainer","Project URL","AUR URL","License", "Votes","Description" ]
-infoFields Japanese   = [ "リポジトリ","名前","バージョン","パッケージ状態","管理者","プロジェクト","パッケージページ","ライセンス","投票数","概要" ]
-infoFields Polish     = [ "Repository","Nazwa","Wersja","Status w AUR","Maintainer","URL Projektu","URL w AUR","Licencja","Głosy","Opis" ]
-infoFields Croatian   = [ "Repozitorij","Ime","Verzija","AUR Stanje","Maintainer","URL Projekta","AUR URL","Licenca","Glasovi","Opis" ]
-infoFields Swedish    = [ "Repository","Namn","Version","AUR Status","Maintainer","Projekt URL","AUR URL","Licens","Röster","Beskrivning" ]
-infoFields German     = [ "Repository","Name","Version","AUR Status","Maintainer","Projekt URL","AUR URL","Lizenz","Stimmen","Beschreibung" ]
-infoFields Spanish    = [ "Repository","Nombre","Versión","Estado en AUR","Maintainer","URL del proyecto","URL en AUR","Licencia", "Votos","Descripción" ]
-infoFields Portuguese = [ "Repositório","Nome","Versão","Estado no AUR","Maintainer","URL do projeto","URL no AUR","Licença", "Votos","Descrição" ]
-infoFields French     = [ "Dépôt","Nom","Version","Statut de AUR","Mainteneur","URL du projet","URL AUR","Licence", "Votes","Description" ]
-infoFields Russian    = [ "Репозиторий","Название","Версия","Статус в AUR","Maintainer","URL проекта","URL в AUR","Лицензия", "Рейтинг","Описание" ]
-infoFields Italian    = [ "Repository","Nome","Versione","Stato in AUR","Maintainer","URL del progetto","URL AUR","Licenza","Voti","Descrizione" ]
-infoFields Serbian    = [ "Ризница","Име","Верзија","Статус у AUR-у","Maintainer","Страница пројекта","Страница у AUR-у","Лиценца","Гласови","Опис" ]
-infoFields Norwegian  = [ "Depot","Navn","Versjon","AUR Status","Vedlikeholder","Prosjekt-URL","AUR URL","Lisens", "Stemmer","Beskrivelse" ]
+infoFields English    = [ "Repository","Name","Version","AUR Status","Maintainer","Project URL","AUR URL","License","Depends On","Build Deps","Votes","Description" ]
+infoFields Japanese   = [ "リポジトリ","名前","バージョン","パッケージ状態","管理者","プロジェクト","パッケージページ","ライセンス","従属パッケージ","作成時従属パ","投票数","概要" ]
+infoFields Polish     = [ "Repository","Nazwa","Wersja","Status w AUR","Maintainer","URL Projektu","URL w AUR","Licencja","Depends On","Build Deps","Głosy","Opis" ]
+infoFields Croatian   = [ "Repozitorij","Ime","Verzija","AUR Stanje","Maintainer","URL Projekta","AUR URL","Licenca","Depends On","Build Deps","Glasovi","Opis" ]
+infoFields Swedish    = [ "Repository","Namn","Version","AUR Status","Maintainer","Projekt URL","AUR URL","Licens","Depends On","Build Deps","Röster","Beskrivning" ]
+infoFields German     = [ "Repository","Name","Version","AUR Status","Maintainer","Projekt URL","AUR URL","Lizenz","Depends On","Build Deps","Stimmen","Beschreibung" ]
+infoFields Spanish    = [ "Repository","Nombre","Versión","Estado en AUR","Maintainer","URL del proyecto","URL en AUR","Licencia","Depends On","Build Deps","Votos","Descripción" ]
+infoFields Portuguese = [ "Repositório","Nome","Versão","Estado no AUR","Maintainer","URL do projeto","URL no AUR","Licença","Depends On","Build Deps","Votos","Descrição" ]
+infoFields French     = [ "Dépôt","Nom","Version","Statut de AUR","Mainteneur","URL du projet","URL AUR","Licence","Depends On","Build Deps","Votes","Description" ]
+infoFields Russian    = [ "Репозиторий","Название","Версия","Статус в AUR","Maintainer","URL проекта","URL в AUR","Лицензия","Depends On","Build Deps","Рейтинг","Описание" ]
+infoFields Italian    = [ "Repository","Nome","Versione","Stato in AUR","Maintainer","URL del progetto","URL AUR","Licenza","Depends On","Build Deps","Voti","Descrizione" ]
+infoFields Serbian    = [ "Ризница","Име","Верзија","Статус у AUR-у","Maintainer","Страница пројекта","Страница у AUR-у","Лиценца","Depends On","Build Deps","Гласови","Опис" ]
+infoFields Norwegian  = [ "Depot","Navn","Versjon","AUR Status","Vedlikeholder","Prosjekt-URL","AUR URL","Lisens","Depends On","Build Deps","Stemmer","Beskrivelse" ]
 
 outOfDateMsg :: Bool -> Language -> String
 outOfDateMsg True  English    = red "Out of Date!"

File Aura/Pkgbuild/Base.hs

     where pkgver = head $ value ns "pkgver"
           pkgrel = head $ value ns "pkgrel"
 
+-- | Yields the value of the `depends` field.
+depends :: Namespace -> [String]
+depends = flip value "depends"
+
+makedepends :: Namespace -> [String]
+makedepends = flip value "makedepends"
+
+checkdepends :: Namespace -> [String]
+checkdepends = flip value "checkdepends"
+
 -- One of my favourite functions in this code base.
 pbCustomization :: Buildable -> Aura Buildable
 pbCustomization = foldl (>=>) return [customizepkg,hotEdit]
     return Package
         { pkgNameOf        = baseNameOf b'
         , pkgVersionOf     = trueVersion ns
-        , pkgDepsOf        = concatMap (map parseDep . value ns)
-                             ["depends", "makedepends", "checkdepends"]
+        , pkgDepsOf        = map parseDep $ concatMap ($ ns)
+                             [depends,makedepends,checkdepends]
         , pkgInstallTypeOf = Build b' }