dojang-0.2.1: A cross-platform dotfiles manager
Safe HaskellNone
LanguageHaskell2010

Dojang.Commands.Disambiguation

Description

This module provides disambiguation logic for resolving ambiguous source paths when multiple routes map to the same destination.

Synopsis

Documentation

data AutoSelectMode Source #

The mode for auto-selecting among ambiguous routes.

Constructors

Interactive

Prompt the user interactively to select a route.

AutoSelectFirst

Automatically select the first route without prompting.

ErrorOnAmbiguity

Return an error when routes are ambiguous.

disambiguateRoutes Source #

Arguments

:: forall (i :: Type -> Type). (MonadFileSystem i, MonadIO i) 
=> AutoSelectMode

The auto-select mode.

-> Maybe OsPath

An explicit source path provided via --source option.

-> NonEmpty CandidateRoute

The candidate routes to disambiguate.

-> App i (Maybe RouteResult)

The selected route, or Nothing if disambiguation failed.

Disambiguate routes when multiple candidates exist.

The disambiguation strategy is:

  1. If an explicit source path is provided via --source, use that.
  2. If exactly one source file exists, auto-select it.
  3. Otherwise, apply the AutoSelectMode:

getAutoSelectMode :: MonadIO m => m AutoSelectMode Source #

Get the auto-select mode from the DOJANG_AUTO_SELECT environment variable.

Possible values:

  • "first" - Auto-select the first route without prompting.
  • "error" - Return an error when routes are ambiguous.
  • (unset or other) - Prompt the user interactively.