output URL on project commands (#7578)

* output URL on project commands

* do not put useless URL in output
This commit is contained in:
Ariel Deitcher 2023-06-19 18:09:26 -07:00 committed by GitHub
parent 08114f981e
commit 1b497221bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 27 additions and 29 deletions

View file

@ -128,13 +128,8 @@ func printResults(config closeConfig, project queries.Project) error {
if !config.io.IsStdoutTTY() {
return nil
}
var action string
if config.opts.reopen {
action = "Reopened"
} else {
action = "Closed"
}
_, err := fmt.Fprintf(config.io.Out, "%s project %s\n", action, project.URL)
_, err := fmt.Fprintf(config.io.Out, "%s\n", project.URL)
return err
}

View file

@ -183,7 +183,7 @@ func TestRunClose_User(t *testing.T) {
assert.NoError(t, err)
assert.Equal(
t,
"Closed project http://a-url.com\n",
"http://a-url.com\n",
stdout.String())
}
@ -452,6 +452,6 @@ func TestRunClose_Reopen(t *testing.T) {
assert.NoError(t, err)
assert.Equal(
t,
"Reopened project http://a-url.com\n",
"http://a-url.com\n",
stdout.String())
}

View file

@ -139,7 +139,7 @@ func printResults(config copyConfig, project queries.Project) error {
if !config.io.IsStdoutTTY() {
return nil
}
_, err := fmt.Fprintf(config.io.Out, "Copied project to %s\n", project.URL)
_, err := fmt.Fprintf(config.io.Out, "%s\n", project.URL)
return err
}

View file

@ -457,6 +457,6 @@ func TestRunCopy_Me(t *testing.T) {
assert.NoError(t, err)
assert.Equal(
t,
"Copied project to http://a-url.com\n",
"http://a-url.com\n",
stdout.String())
}

View file

@ -110,7 +110,7 @@ func printResults(config createConfig, project queries.Project) error {
return nil
}
_, err := fmt.Fprintf(config.io.Out, "Created project '%s'\n%s\n", project.Title, project.URL)
_, err := fmt.Fprintf(config.io.Out, "%s\n", project.URL)
return err
}

View file

@ -146,7 +146,7 @@ func TestRunCreate_User(t *testing.T) {
assert.NoError(t, err)
assert.Equal(
t,
"Created project 'a title'\nhttp://a-url.com\n",
"http://a-url.com\n",
stdout.String())
}
@ -214,7 +214,7 @@ func TestRunCreate_Org(t *testing.T) {
assert.NoError(t, err)
assert.Equal(
t,
"Created project 'a title'\nhttp://a-url.com\n",
"http://a-url.com\n",
stdout.String())
}
@ -273,6 +273,6 @@ func TestRunCreate_Me(t *testing.T) {
assert.NoError(t, err)
assert.Equal(
t,
"Created project 'a title'\nhttp://a-url.com\n",
"http://a-url.com\n",
stdout.String())
}

View file

@ -100,7 +100,7 @@ func runDelete(config deleteConfig) error {
return printJSON(config, *project)
}
return printResults(config)
return printResults(config, query.DeleteProject.Project)
}
@ -116,12 +116,12 @@ func deleteItemArgs(config deleteConfig) (*deleteProjectMutation, map[string]int
}
}
func printResults(config deleteConfig) error {
func printResults(config deleteConfig, project queries.Project) error {
if !config.io.IsStdoutTTY() {
return nil
}
_, err := fmt.Fprintf(config.io.Out, "Deleted project\n")
_, err := fmt.Fprintf(config.io.Out, "Deleted project %d\n", project.Number)
return err
}

View file

@ -148,7 +148,8 @@ func TestRunDelete_User(t *testing.T) {
"data": map[string]interface{}{
"deleteProjectV2": map[string]interface{}{
"projectV2": map[string]interface{}{
"id": "project ID",
"id": "project ID",
"number": 1,
},
},
},
@ -171,7 +172,7 @@ func TestRunDelete_User(t *testing.T) {
assert.NoError(t, err)
assert.Equal(
t,
"Deleted project\n",
"Deleted project 1\n",
stdout.String())
}
@ -239,7 +240,8 @@ func TestRunDelete_Org(t *testing.T) {
"data": map[string]interface{}{
"deleteProjectV2": map[string]interface{}{
"projectV2": map[string]interface{}{
"id": "project ID",
"id": "project ID",
"number": 1,
},
},
},
@ -262,7 +264,7 @@ func TestRunDelete_Org(t *testing.T) {
assert.NoError(t, err)
assert.Equal(
t,
"Deleted project\n",
"Deleted project 1\n",
stdout.String())
}
@ -320,7 +322,8 @@ func TestRunDelete_Me(t *testing.T) {
"data": map[string]interface{}{
"deleteProjectV2": map[string]interface{}{
"projectV2": map[string]interface{}{
"id": "project ID",
"id": "project ID",
"number": 1,
},
},
},
@ -343,6 +346,6 @@ func TestRunDelete_Me(t *testing.T) {
assert.NoError(t, err)
assert.Equal(
t,
"Deleted project\n",
"Deleted project 1\n",
stdout.String())
}

View file

@ -150,7 +150,7 @@ func printResults(config editConfig, project queries.Project) error {
return nil
}
_, err := fmt.Fprintf(config.io.Out, "Updated project %s\n", project.URL)
_, err := fmt.Fprintf(config.io.Out, "%s\n", project.URL)
return err
}

View file

@ -226,7 +226,7 @@ func TestRunUpdate_User(t *testing.T) {
assert.NoError(t, err)
assert.Equal(
t,
"Updated project http://a-url.com\n",
"http://a-url.com\n",
stdout.String())
}
@ -324,7 +324,7 @@ func TestRunUpdate_Org(t *testing.T) {
assert.NoError(t, err)
assert.Equal(
t,
"Updated project http://a-url.com\n",
"http://a-url.com\n",
stdout.String())
}
@ -412,7 +412,7 @@ func TestRunUpdate_Me(t *testing.T) {
assert.NoError(t, err)
assert.Equal(
t,
"Updated project http://a-url.com\n",
"http://a-url.com\n",
stdout.String())
}
@ -507,6 +507,6 @@ func TestRunUpdate_OmitParams(t *testing.T) {
assert.NoError(t, err)
assert.Equal(
t,
"Updated project http://a-url.com\n",
"http://a-url.com\n",
stdout.String())
}