mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-30 16:33:32 -06:00
[feature] list commands for both attachment and emojis (#2121)
* [feature] list commands for both attachment and emojis * use fewer commands, provide `local-only` and `remote-only` as filters * envparsing --------- Co-authored-by: Romain de Laage <romain.delaage@rdelaage.ovh> Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
This commit is contained in:
parent
8f38dc2e7f
commit
7b48437f17
7 changed files with 283 additions and 52 deletions
|
|
@ -161,11 +161,13 @@ type Configuration struct {
|
|||
Cache CacheConfiguration `name:"cache"`
|
||||
|
||||
// TODO: move these elsewhere, these are more ephemeral vs long-running flags like above
|
||||
AdminAccountUsername string `name:"username" usage:"the username to create/delete/etc"`
|
||||
AdminAccountEmail string `name:"email" usage:"the email address of this account"`
|
||||
AdminAccountPassword string `name:"password" usage:"the password to set for this account"`
|
||||
AdminTransPath string `name:"path" usage:"the path of the file to import from/export to"`
|
||||
AdminMediaPruneDryRun bool `name:"dry-run" usage:"perform a dry run and only log number of items eligible for pruning"`
|
||||
AdminAccountUsername string `name:"username" usage:"the username to create/delete/etc"`
|
||||
AdminAccountEmail string `name:"email" usage:"the email address of this account"`
|
||||
AdminAccountPassword string `name:"password" usage:"the password to set for this account"`
|
||||
AdminTransPath string `name:"path" usage:"the path of the file to import from/export to"`
|
||||
AdminMediaPruneDryRun bool `name:"dry-run" usage:"perform a dry run and only log number of items eligible for pruning"`
|
||||
AdminMediaListLocalOnly bool `name:"local-only" usage:"list only local attachments/emojis; if specified then remote-only cannot also be true"`
|
||||
AdminMediaListRemoteOnly bool `name:"remote-only" usage:"list only remote attachments/emojis; if specified then local-only cannot also be true"`
|
||||
|
||||
RequestIDHeader string `name:"request-id-header" usage:"Header to extract the Request ID from. Eg.,'X-Request-Id'."`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -203,6 +203,17 @@ func AddAdminTrans(cmd *cobra.Command) {
|
|||
}
|
||||
}
|
||||
|
||||
// AddAdminMediaList attaches flags pertaining to media list commands.
|
||||
func AddAdminMediaList(cmd *cobra.Command) {
|
||||
localOnly := AdminMediaListLocalOnlyFlag()
|
||||
localOnlyUsage := fieldtag("AdminMediaListLocalOnly", "usage")
|
||||
cmd.Flags().Bool(localOnly, false, localOnlyUsage)
|
||||
|
||||
remoteOnly := AdminMediaListRemoteOnlyFlag()
|
||||
remoteOnlyUsage := fieldtag("AdminMediaListRemoteOnly", "usage")
|
||||
cmd.Flags().Bool(remoteOnly, false, remoteOnlyUsage)
|
||||
}
|
||||
|
||||
// AddAdminMediaPrune attaches flags pertaining to media storage prune commands.
|
||||
func AddAdminMediaPrune(cmd *cobra.Command) {
|
||||
name := AdminMediaPruneDryRunFlag()
|
||||
|
|
|
|||
|
|
@ -3374,6 +3374,56 @@ func GetAdminMediaPruneDryRun() bool { return global.GetAdminMediaPruneDryRun()
|
|||
// SetAdminMediaPruneDryRun safely sets the value for global configuration 'AdminMediaPruneDryRun' field
|
||||
func SetAdminMediaPruneDryRun(v bool) { global.SetAdminMediaPruneDryRun(v) }
|
||||
|
||||
// GetAdminMediaListLocalOnly safely fetches the Configuration value for state's 'AdminMediaListLocalOnly' field
|
||||
func (st *ConfigState) GetAdminMediaListLocalOnly() (v bool) {
|
||||
st.mutex.RLock()
|
||||
v = st.config.AdminMediaListLocalOnly
|
||||
st.mutex.RUnlock()
|
||||
return
|
||||
}
|
||||
|
||||
// SetAdminMediaListLocalOnly safely sets the Configuration value for state's 'AdminMediaListLocalOnly' field
|
||||
func (st *ConfigState) SetAdminMediaListLocalOnly(v bool) {
|
||||
st.mutex.Lock()
|
||||
defer st.mutex.Unlock()
|
||||
st.config.AdminMediaListLocalOnly = v
|
||||
st.reloadToViper()
|
||||
}
|
||||
|
||||
// AdminMediaListLocalOnlyFlag returns the flag name for the 'AdminMediaListLocalOnly' field
|
||||
func AdminMediaListLocalOnlyFlag() string { return "local-only" }
|
||||
|
||||
// GetAdminMediaListLocalOnly safely fetches the value for global configuration 'AdminMediaListLocalOnly' field
|
||||
func GetAdminMediaListLocalOnly() bool { return global.GetAdminMediaListLocalOnly() }
|
||||
|
||||
// SetAdminMediaListLocalOnly safely sets the value for global configuration 'AdminMediaListLocalOnly' field
|
||||
func SetAdminMediaListLocalOnly(v bool) { global.SetAdminMediaListLocalOnly(v) }
|
||||
|
||||
// GetAdminMediaListRemoteOnly safely fetches the Configuration value for state's 'AdminMediaListRemoteOnly' field
|
||||
func (st *ConfigState) GetAdminMediaListRemoteOnly() (v bool) {
|
||||
st.mutex.RLock()
|
||||
v = st.config.AdminMediaListRemoteOnly
|
||||
st.mutex.RUnlock()
|
||||
return
|
||||
}
|
||||
|
||||
// SetAdminMediaListRemoteOnly safely sets the Configuration value for state's 'AdminMediaListRemoteOnly' field
|
||||
func (st *ConfigState) SetAdminMediaListRemoteOnly(v bool) {
|
||||
st.mutex.Lock()
|
||||
defer st.mutex.Unlock()
|
||||
st.config.AdminMediaListRemoteOnly = v
|
||||
st.reloadToViper()
|
||||
}
|
||||
|
||||
// AdminMediaListRemoteOnlyFlag returns the flag name for the 'AdminMediaListRemoteOnly' field
|
||||
func AdminMediaListRemoteOnlyFlag() string { return "remote-only" }
|
||||
|
||||
// GetAdminMediaListRemoteOnly safely fetches the value for global configuration 'AdminMediaListRemoteOnly' field
|
||||
func GetAdminMediaListRemoteOnly() bool { return global.GetAdminMediaListRemoteOnly() }
|
||||
|
||||
// SetAdminMediaListRemoteOnly safely sets the value for global configuration 'AdminMediaListRemoteOnly' field
|
||||
func SetAdminMediaListRemoteOnly(v bool) { global.SetAdminMediaListRemoteOnly(v) }
|
||||
|
||||
// GetRequestIDHeader safely fetches the Configuration value for state's 'RequestIDHeader' field
|
||||
func (st *ConfigState) GetRequestIDHeader() (v string) {
|
||||
st.mutex.RLock()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue