diff --git a/CHANGELOG.md b/CHANGELOG.md index 28021a7..992326f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.7.0] - 2023-09-28 + +### Added + +- 'help' and 'github-token' parameter parameter +- command line reference + +### Changed + +- parent set to fj-universe-tool 0.4.7 + +### Fixed + +- removed link from Java and Maven badges +- placeholder in LICENSE set +- software version links + ## [0.6.2] - 2023-09-24 ### Added diff --git a/LICENSE b/LICENSE index cd08577..559bb03 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2017 Matteo a.k.a. Fugerit + Copyright 2017 Matteo Franci a.k.a. Fugerit Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index 228bdaf..c8cfa30 100644 --- a/README.md +++ b/README.md @@ -9,22 +9,39 @@ Simple propject to export github issues to a xls spreadsheet. [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=fugerit-org_github-issue-export&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=fugerit-org_github-issue-export) [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=fugerit-org_github-issue-export&metric=coverage)](https://sonarcloud.io/summary/new_code?id=fugerit-org_github-issue-export) -![Java runtime version](https://img.shields.io/badge/run%20on-java%208+-%23113366.svg?style=for-the-badge&logo=openjdk&logoColor=white) -![Java build version](https://img.shields.io/badge/build%20on-java%2011+-%23ED8B00.svg?style=for-the-badge&logo=openjdk&logoColor=white) -![Apache Maven](https://img.shields.io/badge/Apache%20Maven-3.9.0+-C71A36?style=for-the-badge&logo=Apache%20Maven&logoColor=white) +[![Java runtime version](https://img.shields.io/badge/run%20on-java%208+-%23113366.svg?style=for-the-badge&logo=openjdk&logoColor=white)](https://universe.fugerit.org/src/docs/versions/java8.html) +[![Java build version](https://img.shields.io/badge/build%20on-java%2011+-%23ED8B00.svg?style=for-the-badge&logo=openjdk&logoColor=white)](https://universe.fugerit.org/src/docs/versions/java11.html) +[![Apache Maven](https://img.shields.io/badge/Apache%20Maven-3.9.0+-C71A36?style=for-the-badge&logo=Apache%20Maven&logoColor=white)](https://universe.fugerit.org/src/docs/versions/maven3_9.html) ## Quickstart -### Clone (use master or develop branch for latest snapshot, release/x.x.x branch for stable versions) -git clone https://github.com/fugerit-org/github-issue-export.git +build : -### Build -From base dir : -mvn clean install -P singlepackage +`mvn clean install -P singlepackage` -### Run with a simple gui -java -jar target/dist-github-issue-export-X.X.X.jar +run as gui : -### Run on command line -java -jar target/dist-github-issue-export-X.X.X.jar --gui 0 --owner fugerit-org --repo github-issue-export --lang it --xls-file target/report.xls +`java -jar target/dist-github-issue-export-*.jar` + +run command line : + +``` +java -jar target/dist-github-issue-export-*.jar --gui 0 \ + --owner fugerit-org \ + --repo github-issue-export \ + --lang it \ + --xls-file target/report.xls +``` + +## **parameter help** + +| **name** | **required** | **default** | **description** | **since** | **info** | +|---------------|---------------|---------------|---------------|---------------|---------------| +| `gui` | `false` | `true` | If `true` will open the Export GUI. | 0.6.2 | `true` or `1` will both evaluate to `true`. | +| `owner` | `false` | none | Repository owner (ex. 'fugerit-org'). | 0.6.2 | Required in command line mode (gui parameter = 0). | +| `repo` | `false` | none | Repository name (ex. 'github-issue-export'). | 0.6.2 | Required in command line mode (gui parameter = 0). | +| `xls-file` | `false` | none | Path to the .xls file (ex. 'report.xls'). | 0.6.2 | Required in command line mode (gui parameter = 0). | +| `github-token` | `false` | none | Github auth token. | 0.6.2 | Needed for privare repositories or to increase github api usage limits. | +| `lang` | `false` | none | Language code, currently supported : 'en', 'it'. | 0.6.2 | If not set will default to default locale or en. | +| `help` | `false` | none | Print help about the tool. | 0.1.0 | | diff --git a/pom.xml b/pom.xml index 836171a..a8cc69d 100644 --- a/pom.xml +++ b/pom.xml @@ -3,15 +3,16 @@ 4.0.0 - org.fugerit.java - fj-bom - 1.4.4 + org.fugerit.java.universe + fj-universe-tool + 0.4.7 + org.fugerit.java github-issue-export - 0.6.2 + 0.7.0 jar github-issue-export @@ -25,12 +26,8 @@ - UTF-8 - 1.8 - 1.8 - 8.3.8 - 2.15.2 - 2.15.2 + 8 + org.fugerit.java.github.issue.export.GithubIssueExportMain fugerit-org_github-issue-export @@ -66,53 +63,19 @@ - - org.fugerit.java - fj-core - ${fj-version} - - - - - org.slf4j - slf4j-api - - org.apache.poi - poi - ${poi-version} + poi-ooxml com.fasterxml.jackson.core jackson-core - ${fasterxml-jackson-core-version} com.fasterxml.jackson.core jackson-databind - ${fasterxml-jackson-databind-version} - - - - org.projectlombok - lombok - provided - - - - - junit - junit - test - - - - org.slf4j - slf4j-simple - provided @@ -135,118 +98,6 @@ - - - - singlepackage - - - org.apache.poi - poi-ooxml - - - org.apache.logging.log4j - log4j-api - - - org.apache.logging.log4j - log4j-core - - - org.apache.logging.log4j - log4j-slf4j2-impl - - - - - - org.apache.maven.plugins - maven-jar-plugin - 3.0.2 - - - - true - org.fugerit.java.github.issue.export.GithubIssueExportMain - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-resource - generate-resources - - add-resource - - - - - src/main/config - . - - **/*.xml - - - - - - - - - org.apache.maven.plugins - maven-shade-plugin - 3.1.0 - - - package - - shade - - - - - dist-${project.artifactId}-${project.version} - - - - - - - - jsonschema2pojo - - - - - org.jsonschema2pojo - jsonschema2pojo-maven-plugin - 0.4.33 - - json - ${project.basedir}/src/main/resources/pojo-config/json-source - org.fugerit.java.github.issue.export.model - - - - - - generate - - - - - - - - - - http://www.fugerit.org Fugerit diff --git a/src/main/java/org/fugerit/java/github/issue/export/GithubIssueExport.java b/src/main/java/org/fugerit/java/github/issue/export/GithubIssueExport.java index 2ae1a6b..64cf7ff 100644 --- a/src/main/java/org/fugerit/java/github/issue/export/GithubIssueExport.java +++ b/src/main/java/org/fugerit/java/github/issue/export/GithubIssueExport.java @@ -82,6 +82,7 @@ private GithubIssueExport() {} public static final String ARG_GITHUB_USER = "github_user"; public static final String ARG_GITHUB_PASS = "github_pass"; + public static final String ARG_GITHUB_TOKEN = "github-token"; public static final String ARG_XLSFILE = "xls-file"; @@ -272,7 +273,7 @@ private static String readUrlData( String url, GithubIssueInfo info ) { final String proxyUser = info.getProperty( ARG_PROXY_USER ); final String proxyPass = info.getProperty( ARG_PROXY_PASS ); String githubUser = info.getProperty( ARG_GITHUB_USER ); - String githubPass = info.getProperty( ARG_GITHUB_PASS ); + String githubPass = info.getProperty( ARG_GITHUB_TOKEN, info.getProperty( ARG_GITHUB_PASS ) ); // github_pass is checked for backward compatibility logger.info( "connecting to url : {}(user:{})", url, githubUser ); HttpURLConnection conn; if ( !StringUtils.isEmpty( proxyHost ) && !StringUtils.isEmpty( proxyPort ) ) { @@ -297,7 +298,7 @@ public PasswordAuthentication getPasswordAuthentication() { // the githubPass is used as Bearer token // the githuUser is ignored if ( StringUtils.isNotEmpty( githubPass ) ) { - logger.info( "Set bearer token : {}", githubPass ); + logger.info( "Set bearer token size : {}", githubPass.length() ); conn.setRequestProperty("Authorization", "Bearer "+githubPass ); } } diff --git a/src/main/java/org/fugerit/java/github/issue/export/GithubIssueExportMain.java b/src/main/java/org/fugerit/java/github/issue/export/GithubIssueExportMain.java index bde56b6..213d768 100644 --- a/src/main/java/org/fugerit/java/github/issue/export/GithubIssueExportMain.java +++ b/src/main/java/org/fugerit/java/github/issue/export/GithubIssueExportMain.java @@ -11,13 +11,20 @@ import org.fugerit.java.core.cli.ArgUtils; import org.fugerit.java.core.function.SafeFunction; +import org.fugerit.java.core.io.SafeIO; import org.fugerit.java.core.io.StreamIO; import org.fugerit.java.core.lang.helpers.BooleanUtils; +import org.fugerit.java.core.lang.helpers.ClassHelper; import org.fugerit.java.core.lang.helpers.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; + +@Slf4j public class GithubIssueExportMain { + + private GithubIssueExportMain() {} protected static final Logger logger = LoggerFactory.getLogger(GithubIssueExportMain.class); @@ -35,8 +42,13 @@ public class GithubIssueExportMain { public static final String ARG_COPY_RES = "copy-res"; - public static void main( String[] args ) { - Properties params = ArgUtils.getArgs( args ); + public static final String ARG_HELP = "help"; + + private static void printHelp() { + log.info( "help : \n\n{}", SafeIO.readStringStream( () -> ClassHelper.loadFromDefaultClassLoader( "tool-config/help.txt" ) ) ); + } + + private static void copyRes( Properties params ) { // copy res start SafeFunction.applySilent( () -> { String copyRes = params.getProperty( ARG_COPY_RES ); @@ -51,21 +63,34 @@ public static void main( String[] args ) { } } ); // copy res end - SafeFunction.applySilent( () -> { - String gui = params.getProperty( ARG_GUI, BooleanUtils.BOOLEAN_1 ); - if ( BooleanUtils.isTrue( gui ) ) { - String guiLocale = params.getProperty( ARG_GUI_LOCALE ); - if (guiLocale != null) { - logger.info( "gui locale : {}", guiLocale ); - Locale.setDefault( Locale.forLanguageTag( guiLocale ) ); + } + + public static void handle( Properties params ) { + String help = params.getProperty( ARG_HELP ); + if ( help != null ) { + printHelp(); + } else { + copyRes(params); + SafeFunction.applySilent( () -> { + String gui = params.getProperty( ARG_GUI, BooleanUtils.BOOLEAN_1 ); + if ( BooleanUtils.isTrue( gui ) ) { + String guiLocale = params.getProperty( ARG_GUI_LOCALE ); + if (guiLocale != null) { + logger.info( "gui locale : {}", guiLocale ); + Locale.setDefault( Locale.forLanguageTag( guiLocale ) ); + } + logger.info( "gui mode : {} (default if gui mode, if no gui add --gui 0", gui ); + new GithubIssueGUI( params ); + } else { + logger.info( "no gui mode : {}", gui ); + GithubIssueExport.handle( params ); } - logger.info( "gui mode : {} (default if gui mode, if no gui add --gui 0", gui ); - new GithubIssueGUI( params ); - } else { - logger.info( "no gui mode : {}", gui ); - GithubIssueExport.handle( params ); - } - } ); + } ); + } + } + + public static void main( String[] args ) { + handle( ArgUtils.getArgs( args ) ); } } diff --git a/src/main/resources/tool-config/help.txt b/src/main/resources/tool-config/help.txt new file mode 100644 index 0000000..9e5701e --- /dev/null +++ b/src/main/resources/tool-config/help.txt @@ -0,0 +1,22 @@ +# Github Issue Export + +Simple propject to export github issues to a xls spreadsheet. + +Example : java -jar target/dist-github-issue-export-*.jar + +## parameter help + + --gui If `true` will open the Export GUI. [default:`true`] + + --owner Repository owner (ex. 'fugerit-org'). + + --repo Repository name (ex. 'github-issue-export'). + + --xls-file Path to the .xls file (ex. 'report.xls'). + + --github-token Github auth token. + + --lang Language code, currently supported : 'en', 'it'. + + --help Print help about the tool. + diff --git a/src/main/resources/tool-config/tool-help-config.xml b/src/main/resources/tool-config/tool-help-config.xml new file mode 100644 index 0000000..86469d3 --- /dev/null +++ b/src/main/resources/tool-config/tool-help-config.xml @@ -0,0 +1,73 @@ + + + + Github Issue Export + + Simple propject to export github issues to a xls spreadsheet. + + java -jar target/dist-github-issue-export-*.jar + + + `gui` + `false` + `true` + If `true` will open the Export GUI. + 0.6.2 + `true` or `1` will both evaluate to `true`. + + + + `owner` + `false` + none + Repository owner (ex. 'fugerit-org'). + 0.6.2 + Required in command line mode (gui parameter = 0). + + + + `repo` + `false` + none + Repository name (ex. 'github-issue-export'). + 0.6.2 + Required in command line mode (gui parameter = 0). + + + + `xls-file` + `false` + none + Path to the .xls file (ex. 'report.xls'). + 0.6.2 + Required in command line mode (gui parameter = 0). + + + + `github-token` + `false` + none + Github auth token. + 0.6.2 + Needed for privare repositories or to increase github api usage limits. + + + + `lang` + `false` + none + Language code, currently supported : 'en', 'it'. + 0.6.2 + If not set will default to default locale or en. + + + + `help` + `false` + none + Print help about the tool. + 0.1.0 + + + + \ No newline at end of file diff --git a/src/test/java/test/org/fugerit/java/github/issue/export/TestToolHelpGeneration.java b/src/test/java/test/org/fugerit/java/github/issue/export/TestToolHelpGeneration.java new file mode 100644 index 0000000..a663ef0 --- /dev/null +++ b/src/test/java/test/org/fugerit/java/github/issue/export/TestToolHelpGeneration.java @@ -0,0 +1,40 @@ +package test.org.fugerit.java.github.issue.export; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; + +import org.fugerit.java.doc.base.config.DocConfig; +import org.fugerit.java.doc.base.config.DocException; +import org.fugerit.java.tool.helper.config.ToolHelpConfig; +import org.fugerit.java.tool.helper.facade.ToolHelpFacade; +import org.fugerit.java.tool.helper.handlers.TxtDocTypeHandler; +import org.junit.Assert; +import org.junit.Test; + +public class TestToolHelpGeneration { + + private static final List TYPES = Arrays.asList( DocConfig.TYPE_HTML, DocConfig.TYPE_MD, DocConfig.TYPE_PDF, TxtDocTypeHandler.TYPE ); + + private boolean testWorker( String baseName, ToolHelpConfig config ) throws IOException, DocException { + boolean ok = true; + for ( String type : TYPES ) { + String fileName = baseName+"."+type; + File outputFile = new File( "target", fileName ); + try ( FileOutputStream fos = new FileOutputStream( outputFile ) ) { + ToolHelpFacade.generate(type, config, fos); + } + ok = ok && outputFile.exists(); + } + return ok; + } + + @Test + public void testGneration() throws IOException, DocException { + boolean ok = this.testWorker( "tool_help_default" , ToolHelpConfig.loadSafe( "cl://tool-config/tool-help-config.xml" ) ); + Assert.assertTrue( ok ); + } + +}