Repo for the search and displace core module including the interface to select files and search and displace operations to run on them. https://searchanddisplace.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
2.9 KiB

  1. # Running S&D via CLI
  2. ### Command
  3. `php artisan sd:run {path} {searchers*} {--original}`
  4. The command accepts two arguments:
  5. - path: The path to the document file on which the Search&Displace will run
  6. - searchers: This argument can be one of the following two types:
  7. - file searchers: the argument must only have one group in the format 'path:replace_with' or 'path+displace_with',
  8. where path is the path to a **valid JSON** file
  9. - inline searchers: the argument can have multiple groups of inline searchers in
  10. the format 'key:replace_with' or 'key+displace_with'.
  11. The 'key' represents a valid searcher found in the 'storage/app/searchers' directory, without the '.json' extension.
  12. - --original: This optional argument can be used if the resulted document should be in the original document format
  13. and having the same structure and styles, otherwise the resulted document will be a Markdown file.
  14. The ':replace_with' or '+displace_with' values are optional, not using them will remove the found text strings.
  15. If the 'replace_with' value is used, like for example 'X:example', then all text strings found will be replaced with
  16. the 'example' text.
  17. If the 'displace_with' value is used, like for example 'Y+example', then all text strings found will be replaced with
  18. text composed using the following format: '{DISPLACE_WITH} FOUND TEXT {/DISPLACE_WITH}', so in our example if the
  19. operation finds the text string 'placeholder', then the result will be '{example} placeholder {/example}'.
  20. The resulted Markdown document or the document in the original format will be created in the
  21. same directory as the input document file together with an analysis result file.
  22. ### Examples
  23. Note! These examples work when running the command from the root app directory, otherwise you have to
  24. input the correct paths in the command, including for the 'artisan' file.
  25. - Using valid JSON file searcher and removing all strings found
  26. `php artisan sd:run ./demo-cli/demo_document.pdf ./demo-cli/demo_searcher.json`
  27. - Using valid JSON file searcher and replacing all strings found with the string 'EMAIL'
  28. `php artisan sd:run ./demo-cli/demo_document.pdf ./demo-cli/demo_searcher.json:EMAIL`
  29. - Using valid searcher key (which exists in the directory 'storage/app/searchers') and removing all strings found
  30. `php artisan sd:run ./demo-cli/demo_document.pdf demo_searcher`
  31. - Using valid searcher key (which exists in the directory 'storage/app/searchers') and replacing all strings found with the string 'EMAIL'
  32. `php artisan sd:run ./demo-cli/demo_document.pdf demo_searcher:EMAIL`
  33. - Using valid JSON file searcher and displacing all strings found using 'EMAIL'
  34. `php artisan sd:run ./demo-cli/demo_document.pdf ./demo-cli/demo_searcher.json+EMAIL`
  35. - Using valid searcher key (which exists in the directory 'storage/app/searchers') and
  36. displacing all strings found using 'EMAIL'
  37. `php artisan sd:run ./demo-cli/demo_document.pdf demo_searcher+EMAIL`