44import picocli .CommandLine .Command ;
55import picocli .CommandLine .Option ;
66
7+ import com .fasterxml .jackson .databind .ObjectMapper ;
78import java .io .File ;
8- import java .util .List ;
9+ import java .io .IOException ;
10+ import java .util .Map ;
911
1012
1113@ Command (name = "gendiff" , mixinStandardHelpOptions = true , version = "gendiff 1.1.1" ,
@@ -19,7 +21,8 @@ class App implements Runnable {
1921 @ Option (names = { "-V" , "--version" }, versionHelp = true , description = "Print version information and exit." )
2022 boolean versionInfoRequested ;
2123
22- @ Option (names = { "-f" , "--format " }, paramLabel = "format" , description = "output format [default: stylish]" , defaultValue = "stylish" )
24+ @ Option (names = { "-f" , "--format " }, paramLabel = "format" ,
25+ description = "output format [default: stylish]" , defaultValue = "stylish" )
2326 private String format ;
2427
2528 @ CommandLine .Parameters (index = "0" , paramLabel = "filepath1" , description = "path to first file" )
@@ -30,11 +33,27 @@ class App implements Runnable {
3033
3134
3235 @ Override
33- public void run () {
34- System .out .println ("0" );
36+ public void run () {
37+ try {
38+ Map <String , Object > data1 = JsonParser .readJsonFile (filepath1 );
39+ Map <String , Object > data2 = JsonParser .readJsonFile (filepath2 );
40+
41+ System .out .println ("Файл 1: " + data1 );
42+ System .out .println ("Файл 2: " + data2 );
43+ } catch (IOException e ) {
44+ System .err .println ("Ошибка при чтении файла: " + e .getMessage ());
45+ }
3546 }
3647
3748 public static void main (String [] args ) {
3849 new CommandLine (new App ()).execute (args );
3950 }
40- }
51+
52+ public class JsonParser {
53+ public static Map <String , Object > readJsonFile (String filePath ) throws IOException {
54+ ObjectMapper objectMapper = new ObjectMapper ();
55+ return objectMapper .readValue (new File ("src/main/resources/" + filePath ), Map .class );
56+ }
57+ }
58+ }
59+
0 commit comments