Skip to content

Commit

Permalink
added multi file creating support
Browse files Browse the repository at this point in the history
  • Loading branch information
lnxwizard committed May 28, 2023
1 parent 08f3f35 commit b71f9ec
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 36 deletions.
18 changes: 7 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# touch
![touch_usage](https://github.com/AlperAkca79/touch/assets/91411319/1c5bae94-9ad0-470f-afc5-6f4e207bb03e)

# What is touch?
The touch is a standard command used in the UNIX/Linux operating system to create files for windows.

Expand All @@ -6,27 +9,20 @@ I decided to make this software because there is no touch command in Windows ope

# How to Use?
```
touch fileName
touch <filename>
```

![Usage of touch](https://github.com/AlperAkca79/cat/assets/91411319/8335edec-c433-4e45-b777-4905e6006c7e)

# Requierments
## Operating System
| OS | Is Supported |
|-------------|--------------------|
| OS | Supported? |
| ----------- | ------------------ |
| Windows XP | :x: |
| Windows 7 | :heavy_check_mark: |
| Windows 7 | :heavy_check_mark: |
| Windows 8 | :heavy_check_mark: |
| Windows 8.1 | :heavy_check_mark: |
| Windows 10 | :heavy_check_mark: |
| Windows 11 | :heavy_check_mark: |

## Architecture
| Architecture | Is Supported |
|----------------------|--------------------|
| x86 (32 bit & i386) | :heavy_check_mark: |
| x64 (64 bit & amd64) | :heavy_check_mark: |

# License
[MIT License](LICENSE)
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
touch1.4.0
touch2.0.0
9 changes: 6 additions & 3 deletions cmd/touch/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ import (

func main() {
// check length of command-line arguments, if not equals 2 print usage of touch else create file
if len(os.Args) != 2 {
fmt.Println("Usage: touch fileName")
if len(os.Args) < 2 {
fmt.Println("Usage: touch <filename>")
} else {
touch.CreateFile(os.Args[1])
// multiple file creating support
for i := 1; i < len(os.Args); i++ {
touch.CreateFile(os.Args[i])
}
}
}
9 changes: 5 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ module github.com/AlperAkca79/touch
go 1.20

require (
github.com/fatih/color v1.15.0
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
golang.org/x/sys v0.6.0 // indirect
github.com/cyucelen/marker v0.0.0-20220628090808-ec8d542c2d28
github.com/fatih/color v1.7.0 // indirect
github.com/mattn/go-colorable v0.1.2 // indirect
github.com/mattn/go-isatty v0.0.9 // indirect
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a // indirect
)
28 changes: 18 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
github.com/cyucelen/marker v0.0.0-20220628090808-ec8d542c2d28 h1:p4HankWrVzrgRE/xUIcLmPk6PFKC4VA+cgAWhUTXUqo=
github.com/cyucelen/marker v0.0.0-20220628090808-ec8d542c2d28/go.mod h1:5/bI38IXC5eJ+QxFpBUz0UOHEBiuJ9ltFHyykMisIZg=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.9 h1:d5US/mDsogSGW37IV293h//ZFaeajb69h+EHFsv2xGg=
github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a h1:aYOabOQFp6Vj6W1F80affTUvO9UxmJRx8K0gsfABByQ=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
15 changes: 8 additions & 7 deletions internal/touch/createFile.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"os"
"path/filepath"

"github.com/cyucelen/marker"
"github.com/fatih/color"
)

Expand All @@ -18,6 +19,7 @@ func CreateFile(fileName string) {

// check if the file exists in the current directory
fileInfo, err := os.Stat(filepath.Join(cwd, fileName))

if err != nil {
if os.IsNotExist(err) {
// create file
Expand All @@ -29,15 +31,14 @@ func CreateFile(fileName string) {
// close file
defer createFile.Close()

// set foreground green
color.Set(color.FgGreen)

fmt.Print("Touching ")
// complete message
completeMessage := "Touching " + fileName

// unset foreground color
color.Unset()
// marking word "Touching"
emphasized := marker.Mark(completeMessage, marker.MatchAll("Touching"), color.New(color.FgGreen))

fmt.Println(fileName)
// Printing complete message
fmt.Println(emphasized)
} else {
fmt.Println(err)
}
Expand Down

0 comments on commit b71f9ec

Please sign in to comment.