packages feed

rhbzquery 0.4.3 → 0.4.4

raw patch · 6 files changed

+54/−20 lines, 6 filesdep ~base

Dependency ranges changed: base

Files

ChangeLog.md view
@@ -1,5 +1,10 @@ # rhbzquery releases +## 0.4.4 (2021-09-06)+- experimental '--reverse' command: converts url to args+- add 'arch'/'platform' aliases+- '--list-fields' now prints field aliases too+ ## 0.4.3 (2021-02-15) - support status with '<STATE' and '>STATE' - Bugzilla uses 'notequals' (not 'notequal')
README.md view
@@ -10,13 +10,13 @@  ## Usage examples -`rhbzquery f33 xyz` : Fedora 33 bugs for package xyz+`rhbzquery f34 xyz` : Fedora 34 bugs for package xyz  `rhbzquery closed rawhide xyz` : closed rawhide bugs for package xyz  `rhbzquery --mine` : your open bugs (gets userid from `~/.bugzillarc`) -`rhbzquery rhel8.3 bash` : RHEL 8.3 bash bugs+`rhbzquery rhel8.4 bash` : RHEL 8.4 bash bugs  `rhbzquery "Package Review" reporter_realname="Your Name"` : open package reviews you reported @@ -24,7 +24,7 @@  `rhbzquery component~bugzilla summary~bugzilla` : open bugs with component and summary containing "bugzilla" -`rhbzquery --file f33 xyz` : file a bug against the xyz package in F33+`rhbzquery --file f34 xyz` : file a bug against the xyz package in F34  `rhbzquery --query rhel8 ...`: open an advanced bugzilla search for RHEL 8 
TODO view
@@ -3,3 +3,5 @@ - cc=me, reporter=me - config file: for defining "my team" etc - --count bugs (no such api though)+- query aliases+- abbrev for Fedora Container Images
rhbzquery.cabal view
@@ -1,5 +1,5 @@ name:                rhbzquery-version:             0.4.3+version:             0.4.4 synopsis:            Bugzilla query tool description:         A CLI tool for creating bugzilla queries for bugzilla.redhat.com.@@ -31,7 +31,7 @@                        ParseArg                        Paths_rhbzquery                        User-  build-depends:       base <5+  build-depends:       base >=4.8 && <5                      , bytestring                      , config-ini                      , directory@@ -70,3 +70,4 @@     ghc-options:   -Wall     build-depends: base >= 4 && < 5                  , simple-cmd+    build-tools:   rhbzquery
src/Fields.hs view
@@ -4,10 +4,12 @@   allBzFields,   BzFields(..),   argToFields,-  argToSimpleField+  argToSimpleField,+  fieldAliases   ) where +import Data.Maybe import Data.List.Extra as L import Data.Version import Numeric.Natural@@ -88,19 +90,24 @@     (major:_) ->  [(BzProduct, "Red Hat Enterprise Linux " ++ show major)                   ,(BzVersion, showVersion ver)] --- FIXME move map to allBzFields+fieldAliases :: [(String,String)]+fieldAliases =+  [ ("arch", "rep_platform")+  , ("platform", "rep_platform")+  , ("flag", "flagtypes.name")+  , ("flags", "flagtypes.name")+  , ("itm", "cf_internal_target_milestone")+  , ("itr", "cf_internal_target_release")+  , ("sst", "agile_team.name")+  , ("status", "bug_status")+  , ("summary", "short_desc")+  ]+ mapField :: String -> String mapField f =   let longname =-        case f of-          "itm" -> "cf_internal_target_milestone"-          "itr" -> "cf_internal_target_release"-          "status" -> "bug_status"-          "sst" -> "agile_team.name"-          "summary" -> "short_desc"-          "flag" -> "flagtypes.name"-          "flags" -> "flagtypes.name"-          p -> L.replace "-" "_" p+        let norm = L.replace "-" "_" f+        in fromMaybe norm $ lookup norm fieldAliases   in if longname `elem` ("format":allBzFields)      then longname      else if "cf_" ++ longname `elem` allBzFields
src/Main.hs view
@@ -11,6 +11,7 @@ import Control.Monad.Extra import Data.Bifunctor import qualified Data.ByteString.Char8 as B+import Data.List.Extra import Data.Maybe #if !MIN_VERSION_base(4,11,0) import Data.Monoid ((<>))@@ -36,7 +37,7 @@ import User  data QueryMode = BugList | ListFields | ListOperators | CreateBug-               | QueryPage | APIQuery+               | QueryPage | APIQuery | Reverse   deriving Eq  main :: IO ()@@ -51,16 +52,33 @@      flagWith' ListOperators 'o' "list-operators" "List op search operator types" <|>      flagWith' CreateBug 'f' "file" "File a bug" <|>      flagWith' QueryPage 'q' "query" "Open advanced query page" <|>+     flagWith' Reverse 'r' "reverse" "Convert url query to args" <|>      flagWith BugList APIQuery 'w' "api" "Web API query") <*>+    -- FIXME should really use some and many     many (strArg argHelp)   where     run :: Bool -> Bool -> String -> QueryMode -> [String] -> IO ()-    -- FIXME list aliases-    run _ _ _ ListFields _ = mapM_ putStrLn allBzFields+    run _ _ _ ListFields _ = do+      mapM_ putStrLn allBzFields+      putStrLn $ "\nAliases: " ++ unwords (map fst fieldAliases)+      putStrLn "(also cf_ prefixes are optional)"+     run _ _ _ ListOperators _ =       mapM_ putStrLn $ map showOpHelp operators ++         ["", "content~ uses matches", "content!~ uses notmatches"]-    -- FIXME should really use some and many+    run _ _ _ Reverse [arg] =+      let args = words $ map ampersandSpace $ removeURLPrefix arg+      -- FIXME drop component= and uses aliases (summary), etc+      in putStrLn $ unwords $ map renderStatus (filter (not . ("list_id=" `isPrefixOf`)) args)+      where+        ampersandSpace c =+          if c == '&' then ' ' else c+        removeURLPrefix url =+          if '?' `elem` url then tail (dropWhile (/= '?') url) else url+        renderStatus s =+          if "bug_status=" `isPrefixOf` s+          then lower $ dropPrefix "bug_status=" s+          else s     run _ _ _ _ [] = error' "please give an argument or --help"     run dryrun mine server mode args = do       user <-@@ -94,6 +112,7 @@         QueryPage -> "query.cgi"         ListFields -> "query.cgi" -- unused         ListOperators -> "query.cgi" -- unused+        Reverse -> "query.cgi" -- unused       <> renderQuery True (bzQuery query)      hasStatusSet :: [ArgType] -> Bool