Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
notes-app
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Abhay Menon
notes-app
Commits
a8997420
Commit
a8997420
authored
2 years ago
by
Abhay Menon
Browse files
Options
Downloads
Plain Diff
Merge branch 'main' into '33-set-up-launch-from-command-line'
parents
013c82e9
83aa282d
No related branches found
No related tags found
1 merge request
!2
Resolve "Set up launch from command line"
Pipeline
#83487
passed
2 years ago
Stage: build
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
console/src/main/kotlin/notes/multi/console/Console.kt
+7
-8
7 additions, 8 deletions
console/src/main/kotlin/notes/multi/console/Console.kt
utilities/src/main/kotlin/notes/multi/utilities/Filemanager.kt
+29
-13
29 additions, 13 deletions
...ties/src/main/kotlin/notes/multi/utilities/Filemanager.kt
with
36 additions
and
21 deletions
console/src/main/kotlin/notes/multi/console/Console.kt
+
7
−
8
View file @
a8997420
...
@@ -38,13 +38,13 @@ fun main(args: Array<String>) {
...
@@ -38,13 +38,13 @@ fun main(args: Array<String>) {
}
else
{
}
else
{
if
(
args
.
size
<
2
)
{
if
(
args
.
size
<
2
)
{
val
filename
=
args
[
0
]
val
filename
=
args
[
0
]
// Optional Regex Check for a specific argument format:
// Optional Regex Check for a specific argument format:
MessageUtils
.
verifyFilename
(
filename
,
Regex
(
"^.*[.](md|txt)$"
))
MessageUtils
.
verifyFilename
(
filename
,
Regex
(
"^.*[.](md|txt)$"
))
// if (fileExists) {
// if (fileExists) {
// Filemanager(".").editfile()
// Filemanager(".").editfile()
// } else {
// } else {
// Filemanager(".").createfile()
// Filemanager(".").createfile()
// }
// }
}
else
{
}
else
{
if
(
args
[
0
]
!=
"-d"
)
{
if
(
args
[
0
]
!=
"-d"
)
{
throw
IllegalArgumentException
(
"[ERROR]: First parameter must be the delete flag"
)
throw
IllegalArgumentException
(
"[ERROR]: First parameter must be the delete flag"
)
...
@@ -61,5 +61,4 @@ fun main(args: Array<String>) {
...
@@ -61,5 +61,4 @@ fun main(args: Array<String>) {
}
}
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
utilities/src/main/kotlin/notes/multi/utilities/Filemanager.kt
+
29
−
13
View file @
a8997420
package
notes.multi.utilities
package
notes.multi.utilities
import
java.io.File
import
java.io.File
import
java.io.FileInputStream
import
java.io.InputStream
import
java.util.*
import
kotlin.io.path.exists
class
Filemanager
(
val
dir
:
String
)
{
private
val
directory
=
File
(
dir
)
fun
files
()
:
MutableList
<
File
>
{
class
Filemanager
(
private
val
dir
:
String
,
private
val
name
:
String
)
{
val
retfiles
=
mutableListOf
<
File
>()
private
val
directory
=
File
(
dir
)
private
val
filepath
=
File
(
"$dir/$name"
)
private
val
listfiles
=
mutableListOf
<
File
>()
init
{
for
(
f
in
directory
.
listFiles
()
!!
)
{
for
(
f
in
directory
.
listFiles
()
!!
)
{
if
(
f
.
extension
==
"txt"
||
f
.
extension
==
"md"
)
{
if
(
f
.
extension
==
"txt"
||
f
.
extension
==
"md"
)
{
re
tfiles
.
add
(
f
)
lis
tfiles
.
add
(
f
)
}
}
}
}
return
retfiles
}
}
//returns list of files
fun
files
()
:
MutableList
<
File
>
{
return
listfiles
}
// create and write to that file
fun
writefile
(
line
:
String
)
{
filepath
.
writeText
(
line
)
listfiles
.
add
(
filepath
)
}
// opens and read the existing file
fun
openfile
():
String
{
if
(!
listfiles
.
contains
(
filepath
))
{
return
""
}
val
inputStream
:
InputStream
=
filepath
.
inputStream
()
fun
createfile
()
{
return
inputStream
.
bufferedReader
().
use
{
it
.
readText
()
}
//TODO: Create File
}
}
fun
deletefile
(
path
:
String
)
{
fun
deletefile
():
Boolean
{
//TODO: DELETE FILE
listfiles
.
remove
(
filepath
)
return
filepath
.
delete
()
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment