fixade bug med --help flagsen
This commit is contained in:
parent
2a594eac1d
commit
84aaf2d527
@ -15,7 +15,6 @@ import (
|
||||
"bbash/command/pwd"
|
||||
"bbash/command/rm"
|
||||
"bbash/command/tail"
|
||||
"bbash/command/touch"
|
||||
"bbash/command/whereareyou"
|
||||
"bbash/environment"
|
||||
"bbash/input_parser"
|
||||
@ -52,8 +51,6 @@ func Run_command(in input_parser.Input, env *environment.Env) {
|
||||
cat.Cat(in, env)
|
||||
case "head":
|
||||
head.Head(in, env)
|
||||
case "touch":
|
||||
touch.Touch(in, env)
|
||||
case "rm":
|
||||
rm.Rm(in, env)
|
||||
case "cp":
|
||||
|
||||
@ -21,8 +21,8 @@ func Head(in input_parser.Input, env *environment.Env) {
|
||||
"help": "-help shows this message",
|
||||
}
|
||||
if slices.Contains(in.Flags, "help") {
|
||||
fmt.Printf("Lists Sources in the current working directory")
|
||||
fmt.Printf("Supported flags are:")
|
||||
fmt.Printf("Lists Sources in the current working directory\n")
|
||||
fmt.Printf("Supported flags are:\n")
|
||||
for _, flag := range flagsArray {
|
||||
fmt.Println(flag + flagsDictionary[flag])
|
||||
} // Print flags and there description
|
||||
|
||||
@ -18,10 +18,10 @@ func Ls(in input_parser.Input, env *environment.Env) {
|
||||
"help": "-help shows this message",
|
||||
}
|
||||
if slices.Contains(in.Flags, "help") {
|
||||
fmt.Printf("Lists Sources in the current working directory")
|
||||
fmt.Printf("Supported flags are:")
|
||||
fmt.Printf("Lists Sources in the current working directory\n")
|
||||
fmt.Printf("Supported flags are:\n")
|
||||
for _, flag := range flagsArray {
|
||||
fmt.Println(flag + flagsDictionary[flag])
|
||||
fmt.Println(flag + " " + flagsDictionary[flag])
|
||||
} // Print flags and their description
|
||||
return
|
||||
}
|
||||
|
||||
@ -6,12 +6,16 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
)
|
||||
|
||||
func Rm(in input_parser.Input, env *environment.Env) {
|
||||
file_path := filepath.Join(env.Path, in.Args_raw)
|
||||
stat, err := os.Stat(file_path)
|
||||
if os.IsNotExist(err) {
|
||||
if slices.Contains(in.Flags, "t") {
|
||||
return
|
||||
}
|
||||
fmt.Println(fmt.Sprintf("File does not exist"))
|
||||
return
|
||||
}
|
||||
|
||||
@ -23,8 +23,8 @@ func Tail(in input_parser.Input, env *environment.Env) {
|
||||
"help": "-help shows this message",
|
||||
}
|
||||
if slices.Contains(in.Flags, "help") {
|
||||
fmt.Printf("Lists Sources in the current working directory")
|
||||
fmt.Printf("Supported flags are:")
|
||||
fmt.Printf("Lists Sources in the current working directory\n")
|
||||
fmt.Printf("Supported flags are:\n")
|
||||
for _, flag := range flagsArray {
|
||||
fmt.Println(flag + flagsDictionary[flag])
|
||||
} // Print flags and there description
|
||||
|
||||
@ -1,24 +0,0 @@
|
||||
package touch
|
||||
|
||||
import (
|
||||
"bbash/environment"
|
||||
"bbash/input_parser"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func Touch(in input_parser.Input, env *environment.Env) {
|
||||
file_path := filepath.Join(env.Path, in.Args_raw)
|
||||
_, err := os.Stat(file_path)
|
||||
if !os.IsNotExist(err) {
|
||||
fmt.Print(fmt.Sprintf("File alredy exist!"))
|
||||
return
|
||||
}
|
||||
file, err := os.Create(file_path)
|
||||
if err != nil {
|
||||
fmt.Print(fmt.Sprintf("Error creating file: %s", err.Error()))
|
||||
return
|
||||
}
|
||||
defer file.Close()
|
||||
}
|
||||
@ -7,5 +7,5 @@ import (
|
||||
)
|
||||
|
||||
func Whereareyou(in input_parser.Input, env *environment.Env) {
|
||||
fmt.Println("You're in the thick of it everybody knows!")
|
||||
fmt.Print("You're in the thick of it everybody knows!")
|
||||
}
|
||||
|
||||
@ -4,10 +4,9 @@ import (
|
||||
"bbash/environment"
|
||||
"bufio"
|
||||
"fmt"
|
||||
"golang.org/x/term"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
var prevGhostString string
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user