diff --git a/grapp/build.gradle b/grapp/build.gradle index ca334bf7bb92aeb407de598f9c67e71290a4df03..9a09e736615acd4577860bd9338ae77e8e9e5c6c 100644 --- a/grapp/build.gradle +++ b/grapp/build.gradle @@ -107,10 +107,7 @@ distributions { } - - - -task fatJar(type: Jar) { +tasks.register('fatJar', Jar) { manifest { attributes 'Main-Class': "fr.ulille.grapp.ui.GrappKt" } diff --git a/grapp/gradle/wrapper/gradle-wrapper.properties b/grapp/gradle/wrapper/gradle-wrapper.properties index ffed3a254e91df704a9acc0f2745c0e340d9b582..ae04661ee733431762e7ccf8ab9b7409ed44960c 100644 --- a/grapp/gradle/wrapper/gradle-wrapper.properties +++ b/grapp/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/grapp/pom.xml b/grapp/pom.xml deleted file mode 100644 index c41ad647ca3c38ea27b662d8b7fc3b90773e11e7..0000000000000000000000000000000000000000 --- a/grapp/pom.xml +++ /dev/null @@ -1,94 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - - <modelVersion>4.0.0</modelVersion> - - <groupId>fr.ulille.grapp</groupId> - <artifactId>grapp</artifactId> - <version>0.1</version> - <packaging>jar</packaging> - - <name>fr.ulille.grapp grapp</name> - - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <kotlin.version>1.4.30-RC</kotlin.version> - <kotlin.code.style>official</kotlin.code.style> - <junit.version>4.12</junit.version> - </properties> - - <dependencies> - <dependency> - <groupId>org.jetbrains.kotlin</groupId> - <artifactId>kotlin-stdlib</artifactId> - <version>${kotlin.version}</version> - </dependency> - <dependency> - <groupId>org.jetbrains.kotlin</groupId> - <artifactId>kotlin-test-junit</artifactId> - <version>${kotlin.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>${junit.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>com.fasterxml.jackson.dataformat</groupId> - <artifactId>jackson-dataformat-yaml</artifactId> - <version>2.12.1</version> - </dependency> - <dependency> - <groupId>org.jgrapht</groupId> - <artifactId>jgrapht-core</artifactId> - <version>1.5.0</version> - </dependency> - <dependency> - <groupId>com.fasterxml.jackson.module</groupId> - <artifactId>jackson-module-kotlin</artifactId> - <version>2.12.0</version> - </dependency> - <dependency> - <groupId>com.github.ajalt.clikt</groupId> - <artifactId>clikt-jvm</artifactId> - <version>3.1.0</version> - </dependency> - <dependency> - <groupId>org.jetbrains.kotlinx</groupId> - <artifactId>kotlinx-cli-jvm</artifactId> - <version>0.3.2</version> - </dependency> - </dependencies> - - <build> - <sourceDirectory>src/main/kotlin</sourceDirectory> - <testSourceDirectory>src/test/kotlin</testSourceDirectory> - - <plugins> - <plugin> - <groupId>org.jetbrains.kotlin</groupId> - <artifactId>kotlin-maven-plugin</artifactId> - <version>${kotlin.version}</version> - <executions> - <execution> - <id>compile</id> - <phase>compile</phase> - <goals> - <goal>compile</goal> - </goals> - </execution> - <execution> - <id>test-compile</id> - <phase>test-compile</phase> - <goals> - <goal>test-compile</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - -</project> diff --git a/grapp/src/main/kotlin/fr/ulille/grapp/ui/Grapp.kt b/grapp/src/main/kotlin/fr/ulille/grapp/ui/Grapp.kt index 14330e967877567b1e97f33658d55d04c4220dff..a163c5dffc2645e7b5d8a9d8369088ece008c4de 100644 --- a/grapp/src/main/kotlin/fr/ulille/grapp/ui/Grapp.kt +++ b/grapp/src/main/kotlin/fr/ulille/grapp/ui/Grapp.kt @@ -36,13 +36,13 @@ import fr.ulille.grapp.algorithms.OptimalityCriterion import fr.ulille.grapp.algorithms.PathCombinationOperation import fr.ulille.grapp.graph.* import fr.ulille.grapp.io.* -import java.io.File -import java.io.FileNotFoundException -import java.io.IOException import java.lang.ClassCastException import java.net.URL import java.net.URLClassLoader import fr.ulille.grapp.ui.OutputFormatting.format +import java.io.* +import java.net.ServerSocket +import java.net.Socket import java.util.regex.Pattern /** Runs the application in REPL mode. */ @@ -133,7 +133,7 @@ object Grapp { } } -object MainCommand : CliktCommand (name="", epilog = Messages.helpEpilog) { +object MainCommand : CliktCommand (name="grapp", epilog = Messages.helpEpilog) { override fun run() {} fun myEcho(message: String?, err: Boolean = false) { @@ -472,7 +472,61 @@ object GenYaml : MyCliktCommand(printHelpOnEmptyArgs = true, help=Messages.genYa class GrappError(message: String) : RuntimeException("Erreur: $message") -fun main() { - println(Messages.grappIntro) - Grapp.run(defaultCliktConsole()) + +fun startServer () { + // Open the socket + println("Démarrage serveur") + val ss = ServerSocket(12345) + var command = "" + while(command != "stop") { + val s = ss.accept() + val inputStream = s.getInputStream().bufferedReader() + command = inputStream.readLine() + println("La commande est: $command") + s.close() + } + println("Server stopped") + ss.close() +} + +class CliktConsoleOnSocket (val ss: ServerSocket): CliktConsole { + override val lineSeparator: String = "\n" + + init { + + } + override fun print(text: String, error: Boolean) { + println(text) + } + + override fun promptForLine(prompt: String, hideInput: Boolean): String? { + print(prompt) + val s = ss.accept() + val inputStream = s.getInputStream().bufferedReader() + val command = inputStream.readLine() + inputStream.close() + s.close() + return command + } +} + + + + +fun main(vararg args: String) { + if (args.isEmpty()) { + // On démarre le serveur + println(Messages.grappIntro) + val ss = ServerSocket(12345) + Grapp.run(CliktConsoleOnSocket(ss)) + ss.close() + } else { + // On véhicule la commande vers le serveur + val s = Socket("localhost", 12345) + val outputWriter = BufferedWriter(OutputStreamWriter(s.getOutputStream())) + outputWriter.write(args.joinToString(separator=" ")) + outputWriter.flush() + outputWriter.close() + + } } diff --git a/grapp/src/main/kotlin/fr/ulille/grapp/ui/GrappUIText.kt b/grapp/src/main/kotlin/fr/ulille/grapp/ui/GrappUIText.kt index 2e9fdff40d6611905fd0f0892bb7b5629ea219ac..73c39b859c69661881520451ae545bdbdc7a26b4 100644 --- a/grapp/src/main/kotlin/fr/ulille/grapp/ui/GrappUIText.kt +++ b/grapp/src/main/kotlin/fr/ulille/grapp/ui/GrappUIText.kt @@ -32,11 +32,12 @@ import java.io.File object Messages { // Documentation and bug related val grappIntro = """ - ----------------------------------------------------------------------------------------- - | Grapp : introduction aux graphes en BUT Informatique | - | Taper 'help' pour la liste des commandes disponibles | - | Plus d'information et documentation : https://gitlab.univ-lille.fr/iovka.boneva/grapp | - ----------------------------------------------------------------------------------------- + -------------------------------------------------------------------------------------------- + | Grapp : introduction aux graphes en BUT Informatique | + | Le serveur est lancé. Saisir les commandes sous la forme 'grapp <commande> <arguments>' | + | Saisir 'grapp help' pour la liste des commandes disponibles | + | Plus d'information et documentation : https://gitlab.univ-lille.fr/iovka.boneva/grapp | + -------------------------------------------------------------------------------------------- """//.trimIndent() const val grappYamlDocUrl = "https://gitlab.univ-lille.fr/iovka.boneva/grapp/-/blob/master/doc/grapp-yaml.md" const val implicitGraphDocUrl = "https://gitlab.univ-lille.fr/iovka.boneva/grapp/-/blob/master/doc/implicit-graph.md" diff --git a/grapp/src/main/kotlin/fr/ulille/grapp/ui/Traces.kt b/grapp/src/main/kotlin/fr/ulille/grapp/ui/Traces.kt deleted file mode 100644 index bdc51c932977136afaaa329def0bda8789998f52..0000000000000000000000000000000000000000 --- a/grapp/src/main/kotlin/fr/ulille/grapp/ui/Traces.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2022 Iovka Boneva, Université de Lille - * - * This file is part of Grapp. - * - * Grapp is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Grapp is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Grapp. If not, see <https://www.gnu.org/licenses/> - */ - -package fr.ulille.grapp.ui - -class Traces { - - -} \ No newline at end of file