fix(BREAKING): remove the from-file flag
All checks were successful
REUSE Compliance Check / check (push) Successful in 8s
All checks were successful
REUSE Compliance Check / check (push) Successful in 8s
The from-file flag was used to read text from a file for creating statuses. This flag is now removed and replaced with the file@ prefix with the content flag. For example, --from-file status.md is now replaced with --content file@status.md
This commit is contained in:
parent
c0f1f7d03a
commit
39d9ef1a38
7 changed files with 13 additions and 49 deletions
|
@ -461,7 +461,7 @@ Creates a new status.
|
||||||
```
|
```
|
||||||
- Create a private status from a file.
|
- Create a private status from a file.
|
||||||
```
|
```
|
||||||
enbas create --type status --content-type markdown --visibility private --from-file status.md
|
enbas create --type status --content-type markdown --visibility private --content file@status.md
|
||||||
```
|
```
|
||||||
- Reply to another status.
|
- Reply to another status.
|
||||||
```
|
```
|
||||||
|
@ -505,13 +505,12 @@ Creates a new status.
|
||||||
|------|------|----------|-------------|---------|
|
|------|------|----------|-------------|---------|
|
||||||
| `type` | string | true | The resource you want to create.<br>Here this should be `status`. | |
|
| `type` | string | true | The resource you want to create.<br>Here this should be `status`. | |
|
||||||
| `attachment-id` | string | false | The ID of the media attachment to attach to the status.<br>Use this flag multiple times to attach multiple media. |
|
| `attachment-id` | string | false | The ID of the media attachment to attach to the status.<br>Use this flag multiple times to attach multiple media. |
|
||||||
| `content` | string | false | The content of the status.<br>This flag takes precedence over `from-file`.| |
|
| `content` | string | false | The content of the status.<br>To read the content from a text file, use the `flag@` prefix followed by the path to the file (e.g. `file@status.md`).| |
|
||||||
| `content-type` | string | false | The format that the content is created in.<br>Valid values are `plain` and `markdown`. | plain |
|
| `content-type` | string | false | The format that the content is created in.<br>Valid values are `plain` and `markdown`. | plain |
|
||||||
| `enable-reposts` | boolean | false | The status can be reposted (boosted) by others. | true |
|
| `enable-reposts` | boolean | false | The status can be reposted (boosted) by others. | true |
|
||||||
| `enable-federation` | boolean | false | The status can be federated beyond the local timelines. | true |
|
| `enable-federation` | boolean | false | The status can be federated beyond the local timelines. | true |
|
||||||
| `enable-likes` | boolean | false | The status can be liked (favourtied). | true |
|
| `enable-likes` | boolean | false | The status can be liked (favourtied). | true |
|
||||||
| `enable-replies` | boolean | false | The status can be replied to. | true |
|
| `enable-replies` | boolean | false | The status can be replied to. | true |
|
||||||
| `from-file` | string | false | The path to the file where to read the contents of the status from. | |
|
|
||||||
| `in-reply-to` | string | false | The ID of the status that you want to reply to. | |
|
| `in-reply-to` | string | false | The ID of the status that you want to reply to. | |
|
||||||
| `language` | string | false | The ISO 639 language code that the status is written in.<br>If this is not specified then the default language from your posting preferences will be used. | |
|
| `language` | string | false | The ISO 639 language code that the status is written in.<br>If this is not specified then the default language from your posting preferences will be used. | |
|
||||||
| `media-file` | string | false | The path to the media file.<br>Use this flag multiple times to upload multiple media files. | |
|
| `media-file` | string | false | The path to the media file.<br>Use this flag multiple times to upload multiple media files. | |
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package executor
|
package executor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"codeflow.dananglin.me.uk/apollo/enbas/internal/client"
|
"codeflow.dananglin.me.uk/apollo/enbas/internal/client"
|
||||||
|
@ -108,10 +109,7 @@ func (a *AddExecutor) addNoteToAccount(gtsClient *client.Client) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if a.content == "" {
|
if a.content == "" {
|
||||||
return EmptyContentError{
|
return errors.New("please add content to the status that you want to create")
|
||||||
ResourceType: resourceNote,
|
|
||||||
Hint: "please use --" + flagContent,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := gtsClient.SetPrivateNote(accountID, a.content); err != nil {
|
if err := gtsClient.SetPrivateNote(accountID, a.content); err != nil {
|
||||||
|
|
|
@ -62,7 +62,6 @@ func (c *CreateExecutor) createList(gtsClient *client.Client) error {
|
||||||
func (c *CreateExecutor) createStatus(gtsClient *client.Client) error {
|
func (c *CreateExecutor) createStatus(gtsClient *client.Client) error {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
content string
|
|
||||||
language string
|
language string
|
||||||
visibility string
|
visibility string
|
||||||
sensitive bool
|
sensitive bool
|
||||||
|
@ -94,12 +93,12 @@ func (c *CreateExecutor) createStatus(gtsClient *client.Client) error {
|
||||||
|
|
||||||
if descriptionsExists {
|
if descriptionsExists {
|
||||||
for ind := 0; ind < expectedLength; ind++ {
|
for ind := 0; ind < expectedLength; ind++ {
|
||||||
content, err := utilities.ReadContents(c.mediaDescriptions[ind])
|
mediaDesc, err := utilities.ReadContents(c.mediaDescriptions[ind])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to read the contents from %s: %w", c.mediaDescriptions[ind], err)
|
return fmt.Errorf("unable to read the contents from %s: %w", c.mediaDescriptions[ind], err)
|
||||||
}
|
}
|
||||||
|
|
||||||
mediaDescriptions[ind] = content
|
mediaDescriptions[ind] = mediaDesc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,22 +132,13 @@ func (c *CreateExecutor) createStatus(gtsClient *client.Client) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch {
|
if c.content == "" && len(attachmentIDs) == 0 {
|
||||||
case c.content != "":
|
return errors.New("please add content to the status that you want to create")
|
||||||
content = c.content
|
}
|
||||||
case c.fromFile != "":
|
|
||||||
content, err = utilities.ReadTextFile(c.fromFile)
|
content, err := utilities.ReadContents(c.content)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to get the status contents from %q: %w", c.fromFile, err)
|
return fmt.Errorf("unable to read the contents from %s: %w", c.content, err)
|
||||||
}
|
|
||||||
default:
|
|
||||||
if len(attachmentIDs) == 0 {
|
|
||||||
// TODO: revisit this error type
|
|
||||||
return EmptyContentError{
|
|
||||||
ResourceType: resourceStatus,
|
|
||||||
Hint: "please use --" + flagContent + " or --" + flagFromFile,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
numAttachmentIDs := len(attachmentIDs)
|
numAttachmentIDs := len(attachmentIDs)
|
||||||
|
|
|
@ -61,21 +61,6 @@ func (e UnsupportedShowOperationError) Error() string {
|
||||||
"' is not supported"
|
"' is not supported"
|
||||||
}
|
}
|
||||||
|
|
||||||
type EmptyContentError struct {
|
|
||||||
ResourceType string
|
|
||||||
Hint string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e EmptyContentError) Error() string {
|
|
||||||
message := "the content of this " + e.ResourceType + " should not be empty"
|
|
||||||
|
|
||||||
if e.Hint != "" {
|
|
||||||
message += ", " + e.Hint
|
|
||||||
}
|
|
||||||
|
|
||||||
return message
|
|
||||||
}
|
|
||||||
|
|
||||||
type UnknownCommandError struct {
|
type UnknownCommandError struct {
|
||||||
Command string
|
Command string
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,6 @@ type CreateExecutor struct {
|
||||||
likeable bool
|
likeable bool
|
||||||
replyable bool
|
replyable bool
|
||||||
boostable bool
|
boostable bool
|
||||||
fromFile string
|
|
||||||
inReplyTo string
|
inReplyTo string
|
||||||
language string
|
language string
|
||||||
listRepliesPolicy string
|
listRepliesPolicy string
|
||||||
|
@ -173,7 +172,6 @@ func NewCreateExecutor(
|
||||||
exe.BoolVar(&exe.likeable, "enable-likes", true, "Set to true to allow the status to be liked (favourited)")
|
exe.BoolVar(&exe.likeable, "enable-likes", true, "Set to true to allow the status to be liked (favourited)")
|
||||||
exe.BoolVar(&exe.replyable, "enable-replies", true, "Set to true to allow viewers to reply to the status")
|
exe.BoolVar(&exe.replyable, "enable-replies", true, "Set to true to allow viewers to reply to the status")
|
||||||
exe.BoolVar(&exe.boostable, "enable-reposts", true, "Set to true to allow the status to be reposted (boosted) by others")
|
exe.BoolVar(&exe.boostable, "enable-reposts", true, "Set to true to allow the status to be reposted (boosted) by others")
|
||||||
exe.StringVar(&exe.fromFile, "from-file", "", "The file path where to read the contents from")
|
|
||||||
exe.StringVar(&exe.inReplyTo, "in-reply-to", "", "The ID of the status that you want to reply to")
|
exe.StringVar(&exe.inReplyTo, "in-reply-to", "", "The ID of the status that you want to reply to")
|
||||||
exe.StringVar(&exe.language, "language", "", "The ISO 639 language code for this status")
|
exe.StringVar(&exe.language, "language", "", "The ISO 639 language code for this status")
|
||||||
exe.StringVar(&exe.listRepliesPolicy, "list-replies-policy", "list", "The replies policy of the list")
|
exe.StringVar(&exe.listRepliesPolicy, "list-replies-policy", "list", "The replies policy of the list")
|
||||||
|
|
|
@ -4,7 +4,6 @@ const (
|
||||||
flagAttachmentID = "attachment-id"
|
flagAttachmentID = "attachment-id"
|
||||||
flagContent = "content"
|
flagContent = "content"
|
||||||
flagFrom = "from"
|
flagFrom = "from"
|
||||||
flagFromFile = "from-file"
|
|
||||||
flagInstance = "instance"
|
flagInstance = "instance"
|
||||||
flagListID = "list-id"
|
flagListID = "list-id"
|
||||||
flagListTitle = "list-title"
|
flagListTitle = "list-title"
|
||||||
|
|
|
@ -60,10 +60,6 @@
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "The resource type to action the target resource from (e.g. status)"
|
"description": "The resource type to action the target resource from (e.g. status)"
|
||||||
},
|
},
|
||||||
"from-file": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "The file path where to read the contents from"
|
|
||||||
},
|
|
||||||
"full": {
|
"full": {
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"description": "Set to true to print the build information in full"
|
"description": "Set to true to print the build information in full"
|
||||||
|
@ -257,7 +253,6 @@
|
||||||
{ "flag": "enable-likes", "fieldName": "likeable", "default": "true" },
|
{ "flag": "enable-likes", "fieldName": "likeable", "default": "true" },
|
||||||
{ "flag": "enable-replies", "fieldName": "replyable", "default": "true" },
|
{ "flag": "enable-replies", "fieldName": "replyable", "default": "true" },
|
||||||
{ "flag": "enable-reposts", "fieldName": "boostable", "default": "true" },
|
{ "flag": "enable-reposts", "fieldName": "boostable", "default": "true" },
|
||||||
{ "flag": "from-file", "default": "" },
|
|
||||||
{ "flag": "in-reply-to", "default": "" },
|
{ "flag": "in-reply-to", "default": "" },
|
||||||
{ "flag": "language", "default": "" },
|
{ "flag": "language", "default": "" },
|
||||||
{ "flag": "list-replies-policy", "default": "list" },
|
{ "flag": "list-replies-policy", "default": "list" },
|
||||||
|
|
Loading…
Reference in a new issue