Skip to content

refactor!: inherit mdfluence CLI parser, rename env vars, add auth model#24

Merged
geopanther merged 6 commits into
mainfrom
refactor/cli-parser-mdfluence
May 13, 2026
Merged

refactor!: inherit mdfluence CLI parser, rename env vars, add auth model#24
geopanther merged 6 commits into
mainfrom
refactor/cli-parser-mdfluence

Conversation

@geopanther

@geopanther geopanther commented Apr 28, 2026

Copy link
Copy Markdown
Owner

Summary

Major refactoring of gitfluence CLI to inherit mdfluence's get_parser(), achieving full CLI option parity. Replaces ~150 lines of duplicated argparse with parser inheritance, adds proper auth model, and ensures gitfluence works as a drop-in replacement for mdfluence.

Breaking Changes

  • CONFLUENCE_PROD_HOST renamed to CONFLUENCE_HOST
  • CONFLUENCE_PROD_TOKEN renamed to CONFLUENCE_TOKEN
  • action.yml inputs renamed accordingly

Changes

Parser inheritance

  • Inherit mdfluence get_parser(), remove/re-add args with gitfluence semantics
  • Remove file_list, output, prefix (re-added with different semantics)
  • Re-add preface/postface with template placeholder support

Full mdfluence CLI option support

  • --disable-emoji, --disable-anchor-convert, --render-diagrams, --mmdc-path, --plantuml-path — delegated to mdfluence internals
  • --title override for single-page repos
  • --parent-id / --parent-title scoped to root-level pages only (child pages keep directory structure)
  • --top-level anchors orphan pages to space homepage
  • Prefix page titles and parent_titles in integration mode ({prefix} - {title})

Auth model

  • Token > username+password > interactive prompt > dry-run dummy
  • --host-int, --token-int, --username-int, --password-int for integration target
  • Int mode without int host: full fallback to prod config
  • Int mode with int host: enforce int-specific auth

New CLI features

  • --debug alias for --verbose (mdfluence compat)
  • -n alias for --dry-run
  • --content-type choices enforced (page/blogpost)
  • --insecure flag passed to MinimalConfluence
  • --page-id rejected with user-friendly error

Config resolution

CLI > env > interactive prompt > dry-run dummy

Tests

131 tests, all passing. Coverage for parser inheritance, default overrides, auth decision, config priority, prefix propagation, parent-id scoping, title prefixing, and integration mode.

Note: No ticket reference associated with this PR.

BREAKING CHANGE: Environment variable rename:
- CONFLUENCE_PROD_HOST -> CONFLUENCE_HOST
- CONFLUENCE_PROD_TOKEN -> CONFLUENCE_TOKEN

Replace ~150 lines of duplicated argparse definitions with mdfluence's
get_parser() as base. gitfluence inherits all mdfluence args, overrides 6
defaults (only_changed, strip_top_header, collapse_single_pages, skip_empty,
skip_subtrees_wo_markdown, enable_relative_links), removes incompatible args
(file_list, output, prefix nargs, preface/postface nargs), and re-adds them
with gitfluence semantics.

New features:
- Username/password auth (matching mdfluence: token > user+password)
- --host-int, --token-int, --username-int, --password-int for integration
- --debug alias for --verbose (mdfluence compat)
- -n alias for --dry-run
- --content-type choices enforced (page/blogpost)
- --insecure flag passed to MinimalConfluence verify=
- --page-id rejected with user-friendly error

Config resolution: CLI > env > interactive prompt > dry-run dummy.
Int mode without int host: full fallback to prod config.
Int mode with int host: enforce int-specific auth (no prod fallback).
Update documentation for CONFLUENCE_PROD_HOST -> CONFLUENCE_HOST
and CONFLUENCE_PROD_TOKEN -> CONFLUENCE_TOKEN rename.

Add documentation for new features:
- Username/password auth (token > user+password priority)
- Integration target CLI args (--host-int, --token-int, etc.)
- --debug alias for --verbose, -n alias for --dry-run
- --page-id rejection note
- --content-type choices (page/blogpost)
- --insecure flag
- Login args section for mdfluence pass-through
Finding:   gitpython@3.1.46 has the following known vulnerabilities:
GHSA-rpm5-65cw-6hj4: GitPython has Command Injection via Git options bypass
  Severity: '8.8'; Minimal Fix Version: '3.1.47';
GHSA-x2qx-6953-8485: GitPython: Unsafe option check validates multi_options
before shlex.split...
  Severity: '8.1'; Minimal Fix Version: '3.1.47';
Fix: tie gitpython to >=3.1.47
… only

CLI parent overrides were applied to all pages, flattening the
directory hierarchy. Now only pages without a mdfluence-assigned
parent receive the override; child pages retain their structure.
- Bump mdfluence minimum from 0.2.1 to 0.4.0
- Bump gitpython minimum from 3.1.47 to 3.1.50
- Pin urllib3>=2.7.0 to fix GHSA-mf9v-mfxr-j63j and GHSA-qccp-gfcp-xxvc
- Remove broken rewrite_page_anchors import; delegate anchor conversion,
  emoji processing, and diagram rendering to mdfluence's
  get_pages_from_directory via convert_anchors, enable_emoji,
  render_diagrams, mmdc_path, plantuml_path params
- Add --title override support in _preprocess_page
- Prefix page titles and child parent_titles in integration mode
  (matching mdfluence's prefix behavior)
- Add --top-level homepage anchoring for page moves
- Fix test_cli: convert_anchors -> disable_anchor_convert
- Update test_confluence and test_integration for prefix behavior
@geopanther geopanther merged commit efa5eec into main May 13, 2026
5 checks passed
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