-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bce9d5f
commit cfad769
Showing
10 changed files
with
250 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* | ||
File | ||
https://github.com/virtualdogbert/GroovyConfigWriter/blob/master/build.gradle | ||
has been used as basis for this file. | ||
*/ | ||
plugins { | ||
id "groovy" | ||
id "maven-publish" | ||
id "idea" | ||
id "jacoco" | ||
id "org.springframework.boot" version "2.1.1.RELEASE" | ||
id "io.spring.dependency-management" version "1.0.6.RELEASE" | ||
id "enterprise.groovy.plugin" version "1.0.4" | ||
} | ||
|
||
apply plugin: 'com.jfrog.bintray' | ||
bootJar { | ||
baseName = 'cobol-cli' | ||
version = '1.0.0' | ||
} | ||
|
||
ext['groovy.version'] = '2.5.4' | ||
sourceCompatibility = 1.8 | ||
group = "io.i-t" | ||
version = "1.0.0" | ||
description = "Groovy Cobol Transpiler, Runtime environment and API" | ||
|
||
repositories { | ||
jcenter() | ||
maven { | ||
url "https://dl.bintray.com/infinite-technology/io.i-t" | ||
} | ||
} | ||
|
||
sourceSets { | ||
main.groovy.srcDirs = ["src/main/groovy"] | ||
test.groovy.srcDirs = ["src/test/groovy"] | ||
} | ||
|
||
dependencies { | ||
compile project(':cobol-lib') | ||
compile 'info.picocli:picocli:4.2.0' | ||
} | ||
|
||
task sourceJar(type: Jar) { | ||
from sourceSets.main.allSource | ||
classifier "sources" | ||
} | ||
|
||
ext { | ||
theTitle = "Groovy Cobol Transpiler, Runtime environment and API" | ||
titleForDocumentation = archivesBaseName + " " + version | ||
packageTitle = group | ||
description = "Groovy Cobol Transpiler, Runtime environment and API" | ||
} | ||
|
||
publishing { | ||
publications { | ||
groovyMaven(MavenPublication) { | ||
from components.java | ||
artifact(sourceJar) { | ||
classifier "sources" | ||
} | ||
} | ||
} | ||
} | ||
|
||
task jarSrc(type: Jar, dependsOn: classes) { | ||
classifier = "sources" | ||
from sourceSets.main.allSource | ||
} | ||
|
||
artifacts { | ||
archives(jarSrc) | ||
} | ||
|
||
bintray { | ||
user = System.getenv("bintrayuser") | ||
key = System.getenv("bintraypassword") | ||
System.out.println(user) | ||
System.out.println(key) | ||
publications = ["groovyMaven"] | ||
def projectName = project.name | ||
def projectDescription = project.description | ||
pkg { | ||
userOrg = "infinite-technology" | ||
repo = "io.i-t" | ||
name = "cobol-cli" | ||
desc = "Groovy Cobol Transpiler, Runtime environment and API" | ||
issueTrackerUrl = "https://github.com/INFINITE-TECHNOLOGY/COBOL/issues" | ||
vcsUrl = "https://github.com/INFINITE-TECHNOLOGY/COBOL.git" | ||
websiteUrl = "https://i-t.io/Cobol" | ||
licenses = ["Apache-2.0"] | ||
} | ||
} | ||
|
||
configurations { | ||
providedRuntime | ||
compile.exclude(group: 'ch.qos.logback') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
Map conventions = [ | ||
disable : false, | ||
whiteListScripts : true, | ||
|
||
disableDynamicCompile : false, | ||
dynamicCompileWhiteList : [], | ||
|
||
compileStaticExtensions : [], | ||
limitCompileStaticExtensions: false, | ||
|
||
defAllowed : false, | ||
skipDefaultPackage : false | ||
] | ||
System.setProperty('enterprise.groovy.conventions', "conventions=${conventions.inspect()}") |
29 changes: 29 additions & 0 deletions
29
cobol-cli/src/main/groovy/io/infinite/cobol/LineBreakEnum.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package io.infinite.cobol | ||
|
||
enum LineBreakEnum { | ||
|
||
CRLF([(byte) 13, (byte) 10], "CRLF"), | ||
CR([(byte) 13], "CR"), | ||
LF([(byte) 10], "LF"), | ||
LFCR([(byte) 10, (byte) 13], "LFCR"), | ||
NL([(byte) 21], "NL"), | ||
NONE([], "NONE") | ||
|
||
private final String label | ||
|
||
private final List<Byte> bytes | ||
|
||
LineBreakEnum(List<Byte> bytes, String label) { | ||
this.label = label | ||
this.bytes = bytes | ||
} | ||
|
||
List<Byte> asBytes() { | ||
return bytes | ||
} | ||
|
||
String asLabel() { | ||
return label | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package io.infinite.cobol | ||
|
||
import groovy.util.logging.Slf4j | ||
import io.infinite.blackbox.BlackBox | ||
import io.proleap.cobol.preprocessor.CobolPreprocessor | ||
import picocli.CommandLine | ||
|
||
import java.util.concurrent.Callable | ||
|
||
@BlackBox | ||
@Slf4j | ||
@CommandLine.Command(name = "COBOL-CLI", mixinStandardHelpOptions = true, description = "Convert COBOL data file to XML.", version = "1.0.0") | ||
class Main implements Callable<Integer> { | ||
|
||
@CommandLine.Parameters(index = "0", description = "Copybook file.") | ||
File copybookFile | ||
|
||
@CommandLine.Parameters(index = "1", description = "COBOL data file") | ||
File dataFile | ||
|
||
@CommandLine.Parameters(index = "2", description = "Result XML file") | ||
File resultFile | ||
|
||
@CommandLine.Option(names = ["-e", "--encoding"], description = "COBOL data file character encoding, i.e. 037 (EBCDIC), ASCII, etc", defaultValue = "037", showDefaultValue = CommandLine.Help.Visibility.ALWAYS) | ||
String encoding | ||
|
||
@CommandLine.Option(names = ["-s", "--structure"], description = "Copybook structure.\nUse if your file has header and/or trailer.\nDefault: \${DEFAULT-VALUE}\nSupported: \${COMPLETION-CANDIDATES}") | ||
CopybookStructureEnum structure = CopybookStructureEnum.DETAILS | ||
|
||
@CommandLine.Option(names = ["-l", "--lineBreak"], description = "Specify line break sequence\nUse if COBOL data file is already split by lines.\nDefault: \${DEFAULT-VALUE}\nSupported: \${COMPLETION-CANDIDATES}") | ||
LineBreakEnum lineBreak = LineBreakEnum.NONE | ||
|
||
@CommandLine.Option(names = ["-f", "--copybookFormat"], description = "Copybook format\nDefault: \${DEFAULT-VALUE}\nSupported: \${COMPLETION-CANDIDATES}") | ||
CobolPreprocessor.CobolSourceFormatEnum copybookFormat = CobolPreprocessor.CobolSourceFormatEnum.FIXED | ||
|
||
static void main(String[] args) { | ||
log.info("Welcome to Infinite Technology COBOL.") | ||
log.info("This is Open Source software, free for usage and modification.") | ||
log.info("By using this software you accept License and User Agreement.") | ||
log.info("Visit our web site: https://i-t.io/Cobol") | ||
int exitCode = new CommandLine(new Main()).execute(args) | ||
System.exit(exitCode) | ||
} | ||
|
||
Integer call() throws Exception { | ||
CobolCompiler cobolCompiler = new CobolCompiler() | ||
CobolRuntime cobolRuntime = cobolCompiler.compileCobol(copybookFile.getText(), copybookFormat) | ||
cobolRuntime.run( | ||
dataFile.length(), | ||
dataFile.newInputStream(), | ||
encoding, | ||
lineBreak.asBytes(), | ||
new CobolApiXml(resultFile.newOutputStream()), | ||
structure | ||
) | ||
return 0 | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
000010 IDENTIFICATION DIVISION. XXXXXXXX | ||
PROGRAM-ID. UnstringSample. XXXXXXXX | ||
ENVIRONMENT DIVISION. XXXXXXXX | ||
CONFIGURATION SECTION. XXXXXXXX | ||
SPECIAL-NAMES. DECIMAL-POINT IS COMMA. XXXXXXXX | ||
INPUT-OUTPUT SECTION. XXXXXXXX | ||
DATA DIVISION. XXXXXXXX | ||
WORKING-STORAGE SECTION. XXXXXXXX | ||
01 ABCDE-RECORD. XXXXXXXX | ||
XXXXXX 02 ABCDE-REC. XXXXXXXX | ||
03 ABCDE-COMMON. XXXXXXXX | ||
05 ABCDE-DETAILS. XXXXXXXX | ||
10 ABCDE-RECORD-ABC. XXXXXXXX | ||
15 ABCDE-PRI-ABC. XXXXXXXX | ||
20 ABCDE-ABC-AAAAAAAA PIC X(02). XXXXXXXX | ||
20 ABCDE-ABC-ACCT-ABCS. XXXXXXXX | ||
25 ABCDE-ABC-ABC-1 PIC X(02). XXXXXXXX | ||
25 ABCDE-ABC-ABC-2 PIC X(03). XXXXXXXX | ||
25 ABCDE-ABC-ABC-3 PIC X(03). XXXXXXXX | ||
25 ABCDE-ABC-ABC-4 PIC X(04). XXXXXXXX |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters