Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
cli
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
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
neodarz
cli
Commits
069fcfa5
Verified
Commit
069fcfa5
authored
6 years ago
by
Eliot Berriot
Browse files
Options
Downloads
Patches
Plain Diff
Added search, artists and albums
parent
f6a827cd
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
funkwhale_cli/cli.py
+18
-3
18 additions, 3 deletions
funkwhale_cli/cli.py
funkwhale_cli/output.py
+21
-2
21 additions, 2 deletions
funkwhale_cli/output.py
with
39 additions
and
5 deletions
funkwhale_cli/cli.py
+
18
−
3
View file @
069fcfa5
...
...
@@ -211,6 +211,7 @@ def get_pagination_data(payload):
def
get_ls_command
(
group
,
endpoint
,
output_conf
):
@group.command
(
"
ls
"
)
@click.argument
(
"
query
"
,
nargs
=-
1
)
@click.option
(
"
--raw
"
,
is_flag
=
True
)
@click.option
(
"
--page
"
,
"
-p
"
,
type
=
click
.
INT
,
default
=
1
)
@click.option
(
"
--page-size
"
,
"
-s
"
,
type
=
click
.
INT
,
default
=
None
)
...
...
@@ -218,7 +219,7 @@ def get_ls_command(group, endpoint, output_conf):
@click.option
(
"
--filter
"
,
"
-f
"
,
multiple
=
True
)
@click.pass_context
@async_command
async
def
ls
(
ctx
,
raw
,
page
,
page_size
,
ordering
,
filter
):
async
def
ls
(
ctx
,
raw
,
page
,
page_size
,
ordering
,
filter
,
query
):
async
with
ctx
.
obj
[
"
remote
"
]:
params
=
{
"
page
"
:
page
}
...
...
@@ -226,6 +227,8 @@ def get_ls_command(group, endpoint, output_conf):
params
[
"
page_size
"
]
=
page_size
if
ordering
:
params
[
"
ordering
"
]
=
ordering
if
query
:
params
[
'
q
'
]
=
'
'
.
join
(
query
)
if
filter
:
for
f
in
filter
:
query
=
urllib
.
parse
.
parse_qs
(
f
)
...
...
@@ -333,10 +336,22 @@ def artists(ctx):
artists_ls
=
get_ls_command
(
artists
,
"
api/v1/artists/
"
,
output_conf
=
{
"
labels
"
:
[
"
ID
"
,
"
Name
"
,
"
Created
"
],
"
type
"
:
"
ARTIST
"
},
output_conf
=
{
"
labels
"
:
[
"
ID
"
,
"
Name
"
,
"
Albums
"
,
"
Tracks
"
,
"
Created
"
],
"
type
"
:
"
ARTIST
"
},
)
@cli.group
()
@click.pass_context
def
albums
(
ctx
):
pass
albums_ls
=
get_ls_command
(
albums
,
"
api/v1/albums/
"
,
output_conf
=
{
"
labels
"
:
[
"
ID
"
,
"
Title
"
,
"
Artist
"
,
"
Tracks
"
,
"
Created
"
],
"
type
"
:
"
ALBUM
"
},
)
@cli.group
()
@click.pass_context
def
tracks
(
ctx
):
...
...
@@ -346,7 +361,7 @@ def tracks(ctx):
tracks_ls
=
get_ls_command
(
tracks
,
"
api/v1/tracks/
"
,
output_conf
=
{
"
labels
"
:
[
"
ID
"
,
"
Title
"
,
"
Artist
"
,
"
Album
"
],
"
type
"
:
"
TRACK
"
},
output_conf
=
{
"
labels
"
:
[
"
ID
"
,
"
Title
"
,
"
Artist
"
,
"
Album
"
,
"
Disc
"
,
"
Position
"
],
"
type
"
:
"
TRACK
"
},
)
...
...
This diff is collapsed.
Click to expand it.
funkwhale_cli/output.py
+
21
−
2
View file @
069fcfa5
...
...
@@ -2,10 +2,25 @@ import tabulate
FIELDS
=
{
"
ARTIST
"
:
{
"
Albums
"
:
{
"
field
"
:
"
albums
"
,
"
handler
"
:
lambda
v
:
len
(
v
),
"
truncate
"
:
0
},
"
Tracks
"
:
{
"
field
"
:
"
albums
"
,
"
handler
"
:
lambda
v
:
sum
([
a
[
"
tracks_count
"
]
for
a
in
v
]),
"
truncate
"
:
0
,
},
"
Artist
"
:
{
"
field
"
:
[
"
album.artist.name
"
,
"
track.artist.name
"
]},
"
Album
"
:
{
"
field
"
:
"
album.title
"
},
},
"
ALBUM
"
:
{
"
Tracks
"
:
{
"
field
"
:
"
tracks
"
,
"
handler
"
:
lambda
v
:
len
(
v
),
"
truncate
"
:
0
},
"
Artist
"
:
{
"
field
"
:
"
artist.name
"
},
},
"
TRACK
"
:
{
"
Title
"
:
{
"
field
"
:
"
title
"
},
"
Artist
"
:
{
"
field
"
:
[
"
album.artist.name
"
,
"
track.artist.name
"
]},
"
Album
"
:
{
"
field
"
:
"
album.title
"
},
"
Disc
"
:
{
"
field
"
:
"
disc
"
,
"
handler
"
:
lambda
v
:
v
or
1
},
"
Position
"
:
{
"
field
"
:
"
position
"
},
},
"
UPLOAD
"
:
{
"
Source
"
:
{
"
field
"
:
"
source
"
},
...
...
@@ -21,6 +36,7 @@ FIELDS = {
"
Uploads
"
:
{
"
field
"
:
"
uploads_count
"
},
},
"
*
"
:
{
"
Title
"
:
{
"
field
"
:
"
title
"
},
"
Created
"
:
{
"
field
"
:
"
creation_date
"
},
"
Name
"
:
{
"
field
"
:
"
name
"
},
"
ID
"
:
{
"
field
"
:
"
id
"
,
"
truncate
"
:
0
},
...
...
@@ -56,8 +72,11 @@ def get_value(obj, config, truncate=30):
value
=
[
recursive_getattr
(
obj
,
f
,
permissive
=
True
)
for
f
in
field
]
value
=
"
/
"
.
join
([
str
(
v
)
for
v
in
value
if
v
is
not
None
])
else
:
value
=
str
(
recursive_getattr
(
obj
,
field
,
permissive
=
True
)
)
value
=
recursive_getattr
(
obj
,
field
,
permissive
=
True
)
if
config
.
get
(
"
handler
"
):
value
=
config
[
"
handler
"
](
value
)
value
=
str
(
value
)
if
truncate
and
len
(
value
)
>
truncate
:
value
=
value
[:
truncate
]
+
"
…
"
return
value
...
...
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