Skip to content

Commit

Permalink
added coloration
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedsaheed committed Jun 26, 2022
1 parent d28ed6d commit 8a52f40
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 7 deletions.
Binary file modified .gradle/7.4/executionHistory/executionHistory.bin
Binary file not shown.
Binary file modified .gradle/7.4/executionHistory/executionHistory.lock
Binary file not shown.
Binary file modified .gradle/7.4/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified .gradle/7.4/fileHashes/fileHashes.lock
Binary file not shown.
Binary file modified .gradle/7.4/fileHashes/resourceHashesCache.bin
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
Binary file modified build/classes/java/main/quranCLI$search.class
Binary file not shown.
Binary file modified build/classes/java/main/quranCLI.class
Binary file not shown.
Binary file modified build/tmp/compileJava/previous-compilation-data.bin
Binary file not shown.
Binary file modified classes/quranCLI$search.class
Binary file not shown.
Binary file modified classes/quranCLI.class
Binary file not shown.
30 changes: 23 additions & 7 deletions src/main/java/quranCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
import org.json.JSONObject;
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Help.Ansi;
import picocli.CommandLine.Option;

import java.awt.event.KeyEvent;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.net.URL;
Expand Down Expand Up @@ -90,17 +92,24 @@ static String GetJuz(int Juz) throws IOException {
public static String GetSurah(int surahNumber) throws IOException {
String url = "http://api.alquran.cloud/v1/surah/" + surahNumber;
StringBuilder verses = new StringBuilder();
String line = new String(new char[48]).replace('\0', '-');

try {
JSONObject jsonObject = new JSONObject(makeRequest(url));
JSONObject data = jsonObject.getJSONObject("data");
//GET SURAH ARABIC NAME
String name = data.getString("name");
//verses.append(name).append("\n");
String names = data.getString("name");
String name = Ansi.AUTO.string("@|bold,magenta,underline " + names + "|@");
System.out.println(line);
System.out.printf("|%s|%n",
StringUtils.center(StringUtils.center(name, 50), 50, ""));
System.out.println(line);

int w = 20;

System.out.println(StringUtils.rightPad("+", w - 1, "-") + "+");
System.out.println(StringUtils.center(StringUtils.center(name, w - 2), w, "|"));
System.out.println(StringUtils.rightPad("+", w - 1, "-") + "+");
// System.out.println(StringUtils.rightPad("+", w - 1, "-") + "+");
// System.out.println(StringUtils.center(StringUtils.center(name, w - 2), w, "|"));
// System.out.println(StringUtils.rightPad("+", w - 1, "-") + "+");
System.out.println("\n");
//GET THE ARABIC TEXT OF THE SURAH
JSONArray ayahs = data.getJSONArray("ayahs");
Expand All @@ -116,7 +125,7 @@ public static String GetSurah(int surahNumber) throws IOException {
}
int width = 50;
System.out.println(StringUtils.rightPad("+", width - 1, "-") + "+");
System.out.println(StringUtils.center(StringUtils.center(verses.toString(), width - 2), width, "|"));
System.out.println(StringUtils.center(StringUtils.center(Ansi.AUTO.string("@|bold,blue " + verses.toString() + "|@"), width - 2), width, "|"));
System.out.println(StringUtils.rightPad("+", width - 1, "-") + "+");
return verses.toString();
}
Expand Down Expand Up @@ -192,6 +201,13 @@ public static void playAudio(String path) {
}
}

// public static void KEYLISTENER(KeyEvent e){
// if(e.getKeyCode() == KeyEvent.VK_SPACE){
// System.out.println("Good Bye");
// System.exit(0);
// }
// }


@Option(names = {"-s", "--surah-number"}, description = "find a surah by it's number in range 1..114")
private int surahNumber;
Expand Down Expand Up @@ -236,7 +252,7 @@ public Integer call() throws Exception { // your business logic goes here...
// this example implements Callable, so parsing, error handling and handling user
// requests for usage help or version help can be done with one line of code.
public static void main(String... args) {
int exitCode = new CommandLine(new quranCLI()).setColorScheme(colorScheme).execute(args);
int exitCode = new CommandLine(new quranCLI()).setColorScheme(colorScheme).execute("-s","1");
// System.exit(exitCode);
}
}

0 comments on commit 8a52f40

Please sign in to comment.