Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ab5370655049c955 pass 132c5c459fe96db10bf3734c42e5b7c22da499f21947b0ecabc942cf66d06e27

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
d4d2c585d96c2f39 pass 5d5fcc4f2dc239f0b0545d951f2892cd5486e42e0db3ef31842edfdf5e765f65

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fe1fa86f2d4650c1 pass 864d04ecf65a3919b39c5507438050e8f622bd4f33bd0f16986860e579844e7c

This file was deleted.

This file was deleted.

5 changes: 3 additions & 2 deletions unison-cli/src/ArgParse.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import Options.Applicative.Builder.Internal (noGlobal {- https://github.com/pcap
import Options.Applicative.Help (bold, (<+>))
import Options.Applicative.Help.Pretty qualified as P
import Stats
import System.Environment (lookupEnv)
import System.Environment (lookupEnv, withProgName)
import Text.Megaparsec qualified as Megaparsec
import Unison.Codebase.Path qualified as Path
import Unison.Codebase.Path.Parse qualified as Path
Expand Down Expand Up @@ -164,7 +164,8 @@ parseCLIArgs progName version = do
let parserInfo = rootParserInfo progName version envOpts
let preferences = prefs $ showHelpOnError <> helpShowGlobals <> columns cols <> subparserInline
let usage = renderUsage progName parserInfo preferences
(globalOptions, command) <- customExecParser preferences parserInfo
-- optparse-applicative looks the program name up itself, for the usage lines it prints
(globalOptions, command) <- withProgName progName $ customExecParser preferences parserInfo
pure $ (usage, globalOptions, command)

-- | Load default options from environment variables.
Expand Down
16 changes: 13 additions & 3 deletions unison-cli/src/Unison/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ main version = do
interruptHandler <- defaultInterruptHandler
withInterruptHandler interruptHandler $ do
void $ Ki.fork scope (initHTTPClient version)
progName <- getProgName
progName <- getUserFacingProgName
-- hSetBuffering stdout NoBuffering -- cool
(renderUsageInfo, globalOptions, command) <- parseCLIArgs progName (Text.unpack (Version.gitDescribeWithDate version))
let GlobalOptions {codebasePathOption = mCodePathOption, exitOption, lspFormattingConfig, jitOption, jitDumpIROption} = globalOptions
Expand Down Expand Up @@ -457,6 +457,16 @@ initHTTPClient version = do
manager <- HTTP.newTlsManagerWith managerSettings
HTTP.setGlobalManager manager

-- | The name to show users for this program, in help text and messages.
--
-- The release bundle and the Nix package start the @unison@ executable from a @ucm@ launcher, so 'getProgName' gives
-- @unison@, a command users don't have.
getUserFacingProgName :: IO String
getUserFacingProgName =
getProgName <&> \case
"unison" -> "ucm"
name -> name

-- | Prep the codebase for transcripts, then pass the directory to the action.
-- After the action the codebase will be deleted/copied/saved as indicated.
withTranscriptDir :: Verbosity.Verbosity -> String -> TranscriptCodebaseSetup -> Maybe CodebasePathOption -> (FilePath -> IO r) -> IO (Maybe r)
Expand Down Expand Up @@ -642,7 +652,7 @@ runTranscripts jit version verbosity renderUsageInfo codebaseSetup mCodePathOpti
putStrLn (renderUsageInfo $ Just "transcript")
Exit.exitWith (Exit.ExitFailure 1)
Success markdownFiles -> pure markdownFiles
progName <- getProgName
progName <- getUserFacingProgName
completed <-
fromMaybe False <$> withTranscriptDir verbosity progName codebaseSetup mCodePathOption \transcriptDir -> do
runTranscripts' jit version progName transcriptDir markdownFiles
Expand Down Expand Up @@ -714,7 +724,7 @@ getCodebaseOrExit codebasePathOption locking migrationStrategy action = do
Left (dir, err) ->
let message = do
pDir <- prettyDir dir
executableName <- P.text . Text.pack <$> getProgName
executableName <- P.text . Text.pack <$> getUserFacingProgName

case err of
InitErrorOpen err ->
Expand Down