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.
 
 
 
 
 
 

2.9 KiB

Running S&D via CLI

Command

php artisan sd:run {path} {searchers*} {--original}

The command accepts two arguments:

  • path: The path to the document file on which the Search&Displace will run
  • searchers: This argument can be one of the following two types:
    • file searchers: the argument must only have one group in the format 'path:replace_with' or 'path+displace_with', where path is the path to a valid JSON file
    • inline searchers: the argument can have multiple groups of inline searchers in the format 'key:replace_with' or 'key+displace_with'. The 'key' represents a valid searcher found in the 'storage/app/searchers' directory, without the '.json' extension.
  • --original: This optional argument can be used if the resulted document should be in the original document format and having the same structure and styles, otherwise the resulted document will be a Markdown file.

The ':replace_with' or '+displace_with' values are optional, not using them will remove the found text strings.

If the 'replace_with' value is used, like for example 'X:example', then all text strings found will be replaced with the 'example' text.

If the 'displace_with' value is used, like for example 'Y+example', then all text strings found will be replaced with text composed using the following format: '{DISPLACE_WITH} FOUND TEXT {/DISPLACE_WITH}', so in our example if the operation finds the text string 'placeholder', then the result will be '{example} placeholder {/example}'.

The resulted Markdown document or the document in the original format will be created in the same directory as the input document file together with an analysis result file.

Examples

Note! These examples work when running the command from the root app directory, otherwise you have to input the correct paths in the command, including for the 'artisan' file.

  • Using valid JSON file searcher and removing all strings found php artisan sd:run ./demo-cli/demo_document.pdf ./demo-cli/demo_searcher.json

  • Using valid JSON file searcher and replacing all strings found with the string 'EMAIL' php artisan sd:run ./demo-cli/demo_document.pdf ./demo-cli/demo_searcher.json:EMAIL

  • Using valid searcher key (which exists in the directory 'storage/app/searchers') and removing all strings found php artisan sd:run ./demo-cli/demo_document.pdf demo_searcher

  • Using valid searcher key (which exists in the directory 'storage/app/searchers') and replacing all strings found with the string 'EMAIL' php artisan sd:run ./demo-cli/demo_document.pdf demo_searcher:EMAIL

  • Using valid JSON file searcher and displacing all strings found using 'EMAIL' php artisan sd:run ./demo-cli/demo_document.pdf ./demo-cli/demo_searcher.json+EMAIL

  • Using valid searcher key (which exists in the directory 'storage/app/searchers') and displacing all strings found using 'EMAIL' php artisan sd:run ./demo-cli/demo_document.pdf demo_searcher+EMAIL