mirror of
https://github.com/Eyre-S/sekai-scores.git
synced 2024-11-22 03:04:55 +08:00
add parse for --user param in add command
This commit is contained in:
parent
16617011a3
commit
0ad227ac8e
@ -1,4 +1,4 @@
|
||||
## Project Configurations
|
||||
|
||||
# Proj Metadata
|
||||
moduleVersion = 0.5
|
||||
moduleVersion = 0.5.1
|
||||
|
@ -2,17 +2,45 @@ package cc.sukazyo.sekai_cli.client;
|
||||
|
||||
import cc.sukazyo.sekai_scores.ScoreBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.InputMismatchException;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
|
||||
import static cc.sukazyo.sekai_cli.Log._debug;
|
||||
import static cc.sukazyo.sekai_cli.Log._user;
|
||||
|
||||
public class AddScore {
|
||||
|
||||
public static void main (String[] args) {
|
||||
|
||||
// process params available in add command
|
||||
Long user_sekai_id = null;
|
||||
final List<String> $args = new ArrayList<>(List.of(args));
|
||||
int $arg_i;
|
||||
if (($arg_i = $args.indexOf("--user")) != -1) {
|
||||
// subcommand --user to use a user instead of the user.id defined in Config
|
||||
$args.remove($arg_i);
|
||||
try {
|
||||
user_sekai_id = Long.parseLong($args.get($arg_i));
|
||||
$args.remove($arg_i);
|
||||
_debug("add: defined user id to use by param: " + user_sekai_id);
|
||||
}
|
||||
catch (IndexOutOfBoundsException e) {
|
||||
_user("add: param --user need a number as user_id.\n use `--user <user_id>` to make it work properly.");
|
||||
_debug(e);
|
||||
} catch (NumberFormatException e) {
|
||||
_user("add: param --user need a user_id which type should be a number:\n " + e.getMessage());
|
||||
_debug(e);
|
||||
}
|
||||
}
|
||||
args = $args.toArray(String[]::new);
|
||||
|
||||
try {
|
||||
|
||||
///--
|
||||
// scores input
|
||||
|
||||
final int[] scores = new int[9];
|
||||
|
||||
if (args.length == 0) {
|
||||
@ -38,6 +66,10 @@ public class AddScore {
|
||||
scores[6], scores[5], scores[7], scores[8]
|
||||
);
|
||||
|
||||
///--
|
||||
// echo and making confirm
|
||||
|
||||
|
||||
System.out.println(PrintScore.printTableScoreBase(scoreBase));
|
||||
|
||||
} catch (ArrayIndexOutOfBoundsException | NumberFormatException e) {
|
||||
|
Loading…
Reference in New Issue
Block a user