- Running ht-refact:
ht-refact [flags] PACKAGE-ROOTS. (PACKAGE-ROOTSstands for the directories containing the cabal files e.g.stack exec ht-refact -- .orstack exec ht-refact -- pkg1 pkg2) - If you don't specify the commands to execute, when the project is loaded the program will start an interactive session. In this session you can use commands to perform refactorings. The source code will be reloaded after each refactoring. When you are finished you can quit the session with the
Exitcommand.
-h,--help: Print out information about the command line arguments of ht-refact. (Does not start the program.)-v,--version: Print out the version of ht-refact. (Does not start the program.)--verbose: Debugging information is logged from the executable.-e COMMANDS,--execute=COMMANDS: Run a one-shot refactoring, specifying the refactor command to execute after the project has been loaded. Multiple commands can be used separated by semicolons (;). See possible commands.--no-watch: Disables file system watching built into the program.-w,--watch-exe PATH: Specify the location of thehfswatchprogram used for file system watching. If not specified it will be expected in the same directory where ht-refact is installed.--generate-code: Always generate interpreted code for modules. Use in cases of GHC linker-related bugs.--no-history: Disables saving the history of performed refactorings. Makes theUndocommand unusable.-g OPTIONS,--ghc-options OPTIONS: Pass flags to GHC to use when parsing and type checking modules. Overrides flags specified in cabal files. See the list of GHC flags. Multiple arguments can be used separated by spaces.--project-type PKG-DB: Restricts the project type to the given one.PKG-DBcan be one of the followings.cabalfor normal cabal projects,cabal-sandboxfor sandbox-based cabal projects,stackfor Stack-based projects or a list of comma-separated file pathes to explicitely set the folders where Haskell packages are loaded.
When the interactive session is started:
- Use the refactorings:
RenameDefinition MODULE SRC-RANGE NEW-NAMEExtractBinding MODULE SRC-RANGE NEW-NAMEInlineBinding MODULE SRC-RANGEGenerateSignature MODULE SRC-RANGEOrganizeImports MODULEGenerateExports MODULEFloatOut MODULE SRC-RANGEProjectOrganizeImports
- A
MODULEis the full module name (for example,Control.Monad), or a unique suffix of the absolute file path of a module (Monad.hsorControl/Monad.hs). - Source ranges can be given in the
startrow:startcol-endrow:endcolformat (for example13:6-14:12). If the start and the end position is the same you can omit the end (13:6). When supplying source ranges, please keep in mind that a tab character causes the insertion of enough spaces to align the current position with the next tab stop. Tab stops are 8 characters apart. - Writing
Trybefore a refactoring command displays the changes as a unified diff instead of actually changing the source files. You can try out the results of a refactoring before you apply it. - When finished, use
Exitto close the CLI. - Using
Undowill take back the last refactoring if the sources were not modified since. - The program automatically reloads the changed modules. If you don't use file system watching (
--no-watch) you can ask the program to re-load your modules by using the 3 commands, to simulate the modification, addition or deletion of a file:ChangeFile FILE-NAMEAddFile FILE-NAMERemoveFile FILE-NAME
- Here
FILE-NAMEshould be the absolute file path of the source file.