Skip to content

Fetch and expand copybooks through Zowe CLI#4

Merged
Tannex merged 8 commits into
mainfrom
zowe-dsn-inputs
Jul 13, 2026
Merged

Fetch and expand copybooks through Zowe CLI#4
Tannex merged 8 commits into
mainfrom
zowe-dsn-inputs

Conversation

@Tannex

@Tannex Tannex commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • add cross-platform Zowe CLI inputs for copybook and binary data DSNs
  • fetch record data with zowe zos-files download data-set --binary into a temporary file, avoiding byte corruption from view --binary
  • recursively expand nested COPY members through ordered DSNSearchPath libraries
  • reject primary input containing a non-comment PROCEDURE DIVISION before COPY resolution
  • load the single JSON configuration source from the platform user-config directory
  • add cq config to create and open that file with the preferred editor

Zowe transfer behavior

Copybooks use the text view path. Record data uses the byte-preserving binary download path, which gives binary mode precedence over profile encoding. cq waits for a successful download before producing JSON and removes the temporary file after decoding. Manual stdin pipelines cannot expose producer failure to cq, so the README documents pipefail and warns against view --binary.

Configuration

The file is config.json under the cq directory returned by Go os.UserConfigDir (XDG config on Linux, Application Support on macOS, and AppData on Windows). cq config creates a minimal file when absent, preserves existing content, and uses VISUAL, EDITOR, or the platform fallback editor.

Validation

  • go test ./...
  • go test -race ./...
  • go vet ./...
  • binary-byte and temporary-file lifecycle tests
  • failed Zowe download produces no cq JSON
  • cq config creation/editor smoke test
  • CLI help smoke test
  • Windows amd64 CLI and test-binary cross-compilation

Live Zowe/z/OSMF transfer could not be exercised in the development workspace; the change is based on user mainframe evidence and the current official Zowe download command/SDK implementation.

Current COPY scope

Simple COPY MEMBER. statements are supported. COPY REPLACING and COPY OF/IN clauses return explicit errors.

Tannex added 8 commits July 13, 2026 20:03
Let cq fetch copybooks as text and stream record data in binary mode through the installed Zowe CLI, avoiding shell-specific process substitution and PowerShell byte-pipeline hazards.

Constraint: Reuse the user's existing Zowe installation and configuration; do not add an SDK dependency.

Rejected: Shell wrappers and temporary files | they remain platform-specific and prevent direct streaming

Confidence: high

Scope-risk: moderate

Directive: Keep copybook Zowe reads in text mode and record-data reads in binary mode.

Tested: GOCACHE=/tmp/cq-go-build go test ./...; GOCACHE=/tmp/cq-go-build go test -race ./...; GOCACHE=/tmp/cq-go-build go vet ./...; Windows amd64 build and test-binary cross-compilation
Expand plain COPY member statements before parsing and resolve each member recursively through a configurable, cached Zowe search hierarchy.

Constraint: Configuration uses DSNSearchPath in cq.json or an explicit --config file.

Rejected: Implicitly search only the root copybook library | enterprise copybooks commonly span several ordered libraries

Rejected: Support COPY REPLACING immediately | token substitution semantics need a separate tested contract

Confidence: high

Scope-risk: moderate

Directive: Preserve first-success DSN ordering and report COPY cycles with the full member chain.

Tested: GOCACHE=/tmp/cq-go-build go test ./...; GOCACHE=/tmp/cq-go-build go test -race ./...; GOCACHE=/tmp/cq-go-build go vet ./...; Windows amd64 application and test-binary cross-compilation
Resolve implicit cq configuration through os.UserConfigDir so Linux, macOS, and Windows use established per-user locations while retaining --config overrides.

Constraint: Missing implicit config remains optional until nested COPY lookup is needed.

Rejected: Search the working directory for cq.json | surprising behavior in arbitrary project directories

Confidence: high

Scope-risk: narrow

Directive: Keep platform defaults derived from os.UserConfigDir.

Tested: GOCACHE=/tmp/cq-go-cache go test ./...; go test -race ./...; go vet ./...; Windows amd64 CLI and test-binary cross-compilation
Remove the explicit config override so nested COPY resolution has one predictable platform-standard configuration source and a smaller CLI surface.

Constraint: DSNSearchPath remains optional until a COPY statement needs resolution.

Rejected: Retain an internal arbitrary-path loader | it preserves unused complexity after removing the flag

Confidence: high

Scope-risk: narrow

Directive: Keep cq configuration rooted at os.UserConfigDir unless a concrete multi-config use case emerges.

Tested: go test ./...; go test -race ./...; go vet ./...; CLI help smoke test; Windows amd64 CLI and test-binary cross-compilation
Add cq config so users can create and open the sole configuration file without locating platform-specific directories manually.

Constraint: Launch editors without a shell and preserve existing configuration content.

Rejected: Reintroduce a config-path flag | it would undo the single-path CLI simplification

Confidence: high

Scope-risk: narrow

Directive: Keep cq config aligned with defaultConfigFile and never overwrite an existing config.

Tested: go test ./...; go test -race ./...; go vet ./...; cq config creation/editor smoke test; CLI help smoke test; Windows amd64 CLI and test-binary cross-compilation
Detect a non-comment PROCEDURE DIVISION in the primary input so whole COBOL programs fail clearly without triggering COPY resolution.

Constraint: Reuse lexer normalization so fixed/free comments and quoted literals do not produce false positives.

Rejected: Validate every recursively fetched member | broader nested-member policy than the requested input guard

Confidence: high

Scope-risk: narrow

Directive: Keep program-source detection ahead of the first resolver call.

Tested: go test ./...; go test -race ./...; go vet ./...; Windows amd64 CLI and test-binary cross-compilation
State that cq neither bundles Zowe CLI nor has Linux Foundation or Zowe project affiliation, while acknowledging the registered trademark.

Constraint: Keep the notice adjacent to the Zowe invocation documentation.

Confidence: high

Scope-risk: narrow

Directive: Revisit licensing and notices before bundling any Zowe artifacts.

Tested: git diff --check; documentation-only change
Use Zowe download-to-file for record data so packed and binary fields reach cq unchanged and Zowe failures are known before JSON output begins.

Constraint: Correct byte preservation takes precedence over streaming; temporary downloads are removed after decoding.

Rejected: zowe zos-files view data-set --binary | observed to corrupt packed-decimal bytes and conflict with profile encoding

Confidence: high

Scope-risk: moderate

Directive: Do not restore the Zowe view path for binary record data without byte-for-byte mainframe evidence.

Tested: go test ./...; go test -race ./...; go vet ./...; CLI help smoke test; Windows amd64 CLI and test-binary cross-compilation

Not-tested: Live Zowe profile and z/OSMF transfer are unavailable in this workspace.
@Tannex
Tannex merged commit 826c149 into main Jul 13, 2026
@Tannex
Tannex deleted the zowe-dsn-inputs branch July 14, 2026 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant