Comments (7)
Definitely possible. If you wanna add it to the CLI, itβs just deleteProject(Id) in our GraphQL API
from cli.
@JakeCooper
I add delete.go
document in cmd/
folder and the content as follow:
package cmd
import (
"context"
"fmt"
"github.com/railwayapp/cli/entity"
"github.com/railwayapp/cli/ui"
"github.com/railwayapp/cli/uuid"
)
func(h *Handler)Delete(ctx context.Context, req *entity.CommandRequest)error{
if len(req.Args) > 0 {
// projectID provided as argument
arg := req.Args[0]
if (uuid.IsValidUUID(arg)) {
project, err := h.ctrl.GetProject(ctx, arg)
if (err != nil) {
return err
}
return h.ctrl.DeleteProject(ctx, project.Id)
}
project, err := h.ctrl.GetProjectByName(ctx, arg)
if (err != nil) {
return err
}
return h.ctrl.DeleteProject(ctx, project.Id)
}
h.Unlink(ctx, req)
isLoggedIn, err := h.ctrl.IsLoggedIn(ctx)
if err != nil {
return err
}
if isLoggedIn {
return h.deleteFromAccount(ctx, req)
} else {
return h.deleteFromID(ctx, req)
}
}
func (h *Handler) deleteFromAccount(ctx context.Context, req *entity.CommandRequest) error {
projects, err := h.ctrl.GetProjects(ctx)
if err != nil {
return err
}
if len(projects) == 0 {
fmt.Printf("No Projects could be deleted.")
return nil
}
project, err := ui.PromptProjects(projects)
if err != nil {
return err
}
return h.ctrl.DeleteProject(ctx, project.Id)
}
func (h *Handler) deleteFromID(ctx context.Context, req *entity.CommandRequest) error {
projectID, err := ui.PromptText("Enter your project id")
if err != nil {
return err
}
project, err := h.ctrl.GetProject(ctx, projectID)
if (err != nil) {
return err
}
return h.ctrl.DeleteProject(ctx, project.Id)
}
append DeleteProject
function in controller/project.go
func (c *Controller) DeleteProject(ctx context.Context, projectID string) error {
return c.gtwy.DeleteProject(ctx, projectID)
}
and append addRootCmd
execution about deleting project operation in init
function which in project's main.go
as follow
addRootCmd(&cobra.Command{
Use: "delete",
Short: "Delete Project, may specify projectId as an argument",
RunE: contextualize(handler.Delete, handler.Panic),
})
the delete operation seems to unsuccessful, any idea?
from cli.
Hey! @TaroballzChen I will be reviewing this once I wake up and working through on why it might not be working. The good news is that the CLI is using all of the same gQL mutations as our front-end so I can check that out and try it against your changes.
from cli.
Hi! @ndneighbor I'm grateful to hear that. If any good news during checking, plz guide me how to do that!
from cli.
Alright, got some news for you- I looked into deleteProject
in the controller of the project and it matches the front-end call. I am going to review with the team to see if there is something else that might have caused the 400.
(I also noticed that if you try to delete a project with an id that doesn't exist it errors out too, so I want to clean up that flow for you as well.)
Thank you for your patience.
from cli.
Alright, this feature is in the latest CLI version @TaroballzChen, try it out and let me know what you think!
from cli.
I have try it, and the result looks good for me. Thanks for your help
from cli.
Related Issues (20)
- [FEATURE REQUEST] make `shell` respect local .env files (configurable with flag overrides) HOT 2
- [CLI] [BUG] `shell` command bugging on ctrl-c when installed from `npm` or `scoop` HOT 1
- railway down not authorized github actions HOT 2
- CLI login error (18) HOT 1
- Can't install railway cli HOT 4
- Errors about streaming logs when deploying from command line HOT 3
- railway up UX revamp tracking issue HOT 21
- Respect the activated environment (or new token with ability to reach all environment) HOT 2
- FEATURE REQUEST: More descriptive errors for cli
- Railway logs command does not use the linked service
- Issue with "railway up" command for Symfony API Project Deployment
- 504 Gateway Timeout HOT 1
- Accessing project's environment directly [CRONJOBS] HOT 2
- `railway shell` not grabbing ctrl+c handler from node when installed via pnpm
- RUSTSEC-2023-0052: webpki: CPU denial of service in certificate path building
- Can not execute CLI when installed as a devDependency via Bun HOT 1
- Gitlab CI error: sending request for url: backboard.railway-develop.app failure HOT 2
- Can't not display Image with Nextjs version : 13.5.3 HOT 1
- RUSTSEC-2023-0065: Tungstenite allows remote attackers to cause a denial of service
- Error: URL Not Found When Installing @railway/cli v3.4.0 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cli.