Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
liber
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ale
liber
Commits
1555c0d9
Commit
1555c0d9
authored
7 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
Add list-books matchers for missing sources and ISBNs
parent
3b4b6075
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
cmd/liber/list.go
+26
-1
26 additions, 1 deletion
cmd/liber/list.go
with
26 additions
and
1 deletion
cmd/liber/list.go
+
26
−
1
View file @
1555c0d9
...
...
@@ -26,7 +26,9 @@ func (c *listCommand) Usage() string {
+incomplete
+invalid
+source:<SOURCE>
-source:<SOURCE>
+nofiles
+noisbn
+missingcover
`
...
...
@@ -46,6 +48,20 @@ func matchSource(source string) func(*liber.Book) bool {
}
}
func
matchMissingSource
(
source
string
)
func
(
*
liber
.
Book
)
bool
{
return
func
(
book
*
liber
.
Book
)
bool
{
if
book
.
Metadata
==
nil
{
return
true
}
for
_
,
msrc
:=
range
book
.
Metadata
.
Sources
{
if
msrc
.
Name
==
source
{
return
false
}
}
return
true
}
}
func
matchNoFiles
(
db
*
liber
.
Database
)
func
(
*
liber
.
Book
)
bool
{
return
func
(
book
*
liber
.
Book
)
bool
{
f
,
_
:=
db
.
GetBookFiles
(
book
.
Id
)
...
...
@@ -65,6 +81,10 @@ func matchIncomplete(book *liber.Book) bool {
return
(
book
.
Metadata
!=
nil
&&
book
.
Metadata
.
Complete
())
}
func
matchNoISBN
(
book
*
liber
.
Book
)
bool
{
return
book
.
Metadata
==
nil
||
len
(
book
.
Metadata
.
ISBN
)
==
0
}
func
matchInvalid
(
_
*
liber
.
Book
)
bool
{
return
false
}
...
...
@@ -75,7 +95,10 @@ func matchAll(_ *liber.Book) bool {
func
(
c
*
listCommand
)
parseTag
(
db
*
liber
.
Database
,
tag
string
)
(
func
(
*
liber
.
Book
)
bool
,
error
)
{
if
strings
.
HasPrefix
(
tag
,
"+source:"
)
{
return
matchSource
(
tag
[
7
:
]),
nil
return
matchSource
(
tag
[
8
:
]),
nil
}
if
strings
.
HasPrefix
(
tag
,
"-source:"
)
{
return
matchMissingSource
(
tag
[
8
:
]),
nil
}
switch
tag
{
...
...
@@ -89,6 +112,8 @@ func (c *listCommand) parseTag(db *liber.Database, tag string) (func(*liber.Book
return
matchNoFiles
(
db
),
nil
case
"+missingcover"
:
return
matchMissingCover
,
nil
case
"+noisbn"
:
return
matchNoISBN
,
nil
default
:
return
nil
,
fmt
.
Errorf
(
"unknown tag '%s'"
,
tag
)
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment