From aeba697d7699965cdea51bc9d37d57b0de3e3d56 Mon Sep 17 00:00:00 2001 From: Eric Loots Date: Wed, 16 Aug 2023 16:07:22 +0200 Subject: [PATCH] Add show cmta progress (#280) - Add some progress feedback for `cmta studentify`, `cmta linearize`, and `cmta delinearize` commands --- cmt-core/src/main/scala/com/lunatech/cmt/Helpers.scala | 1 + .../scala/com/lunatech/cmt/admin/command/Delinearize.scala | 3 ++- .../scala/com/lunatech/cmt/admin/command/Linearize.scala | 3 ++- .../scala/com/lunatech/cmt/admin/command/Studentify.scala | 6 +++--- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/cmt-core/src/main/scala/com/lunatech/cmt/Helpers.scala b/cmt-core/src/main/scala/com/lunatech/cmt/Helpers.scala index 256b4b73..2cfe5cea 100644 --- a/cmt-core/src/main/scala/com/lunatech/cmt/Helpers.scala +++ b/cmt-core/src/main/scala/com/lunatech/cmt/Helpers.scala @@ -159,6 +159,7 @@ object Helpers: def hideExercises(cleanedMainRepo: File, solutionsFolder: File, exercises: Vector[String])(config: CMTaConfig): Unit = val now: Option[Long] = Some(java.time.Instant.now().toEpochMilli()) for (exercise <- exercises) + print(s".") zipAndDeleteOriginal(cleanedMainRepo / config.mainRepoExerciseFolder, solutionsFolder, exercise, now) end hideExercises diff --git a/cmta/src/main/scala/com/lunatech/cmt/admin/command/Delinearize.scala b/cmta/src/main/scala/com/lunatech/cmt/admin/command/Delinearize.scala index 9ce904eb..26934f4b 100644 --- a/cmta/src/main/scala/com/lunatech/cmt/admin/command/Delinearize.scala +++ b/cmta/src/main/scala/com/lunatech/cmt/admin/command/Delinearize.scala @@ -57,7 +57,7 @@ object Delinearize: _ <- putBackToMain(mainRepository.value, linearizedRootFolder, exercisesAndSHAsInLinearized)(config) - successMessage <- Right(s"Successfully delinearised ${options.linearizeBaseDirectory.value.getPath}") + successMessage <- Right(s"\nSuccessfully delinearised ${options.linearizeBaseDirectory.value.getPath}") } yield successMessage } @@ -114,6 +114,7 @@ object Delinearize: exercisesAndSHAs: Seq[ExerciseNameAndSHA]): Either[CmtError, Unit] = exercisesAndSHAs match case ExerciseNameAndSHA(exercise, sha) +: remaining => + print(".") s"git checkout $sha" .toProcessCmd(linearizedRepo) .runWithStatus(toConsoleRed(s"Unable to checkout commit($sha) corresponding to exercise: $exercise")) match diff --git a/cmta/src/main/scala/com/lunatech/cmt/admin/command/Linearize.scala b/cmta/src/main/scala/com/lunatech/cmt/admin/command/Linearize.scala index a769c46f..be56c088 100644 --- a/cmta/src/main/scala/com/lunatech/cmt/admin/command/Linearize.scala +++ b/cmta/src/main/scala/com/lunatech/cmt/admin/command/Linearize.scala @@ -72,7 +72,7 @@ object Linearize: _ <- commitExercises(cleanedMainRepo, exercises, linearizedRootFolder, config) _ = sbtio.delete(tmpFolder) - successMessage <- Right(s"Successfully linearized ${mainRepository.value.getPath}") + successMessage <- Right(s"\nSuccessfully linearized ${mainRepository.value.getPath}") } yield successMessage } @@ -91,6 +91,7 @@ object Linearize: exercises match case exercise +: remainingExercises => + print(".") val from = cleanedMainRepo / config.mainRepoExerciseFolder / exercise val linearizedCodeFolder = linearizedRootFolder / config.linearizedRepoActiveExerciseFolder sbtio.delete(linearizedCodeFolder) diff --git a/cmta/src/main/scala/com/lunatech/cmt/admin/command/Studentify.scala b/cmta/src/main/scala/com/lunatech/cmt/admin/command/Studentify.scala index 94f462e5..5689413d 100644 --- a/cmta/src/main/scala/com/lunatech/cmt/admin/command/Studentify.scala +++ b/cmta/src/main/scala/com/lunatech/cmt/admin/command/Studentify.scala @@ -99,7 +99,7 @@ object Studentify: ExercisesMetadata(prefix, exercises, exerciseNumbers) <- getExerciseMetadata(mainRepository.value)(config) - _ = buildStudentifiedRepository( + buildResult = buildStudentifiedRepository( cleanedMainRepo, exercises, studentifiedRootFolder, @@ -108,7 +108,7 @@ object Studentify: options.initGit, tmpFolder) - successMessage <- Right(exercises.mkString("Processed exercises:\n ", "\n ", "\n")) + successMessage <- buildResult } yield successMessage } @@ -139,7 +139,7 @@ object Studentify: generatorInfo) writeStudentifiedCMTBookmark(studentifiedRootFolder / config.studentifiedRepoBookmarkFile, exercises.head) - val successMessage = exercises.mkString("Processed exercises:\n ", "\n ", "\n") + val successMessage = exercises.mkString("\nProcessed exercises:\n ", "\n ", "\n") if initializeAsGitRepo.value then val dotIgnoreFile = cleanedMainRepo / ".gitignore" if dotIgnoreFile.exists then sbtio.copyFile(dotIgnoreFile, studentifiedRootFolder / ".gitignore")