github.com/symfony-cli/symfony-cli@v0.0.0-20240514161054-ece2df437dfa/commands/local_proxy_domain_detach.go (about) 1 /* 2 * Copyright (c) 2021-present Fabien Potencier <fabien@symfony.com> 3 * 4 * This file is part of Symfony CLI project 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU Affero General Public License as 8 * published by the Free Software Foundation, either version 3 of the 9 * License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU Affero General Public License for more details. 15 * 16 * You should have received a copy of the GNU Affero General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 package commands 21 22 import ( 23 "github.com/symfony-cli/console" 24 "github.com/symfony-cli/symfony-cli/local/proxy" 25 "github.com/symfony-cli/symfony-cli/util" 26 "github.com/symfony-cli/terminal" 27 ) 28 29 var localProxyDetachDomainCmd = &console.Command{ 30 Category: "local", 31 Name: "proxy:domain:detach", 32 Aliases: []*console.Alias{{Name: "proxy:domain:detach"}, {Name: "proxy:domain:remove", Hidden: true}}, 33 Usage: "Detach domains from the proxy", 34 Args: []*console.Arg{ 35 {Name: "domains", Optional: true, Description: "The domains to detach", Slice: true}, 36 }, 37 Action: func(c *console.Context) error { 38 homeDir := util.GetHomeDir() 39 config, err := proxy.Load(homeDir) 40 if err != nil { 41 return err 42 } 43 domains := c.Args().Tail() 44 if err := config.RemoveDirDomains(domains); err != nil { 45 return err 46 } 47 terminal.Println("<info>The following domains are not defined anymore on the proxy:</>") 48 for _, domain := range domains { 49 terminal.Printfln(" * http://%s", domain) 50 } 51 return nil 52 }, 53 }