As a programmer, I’d prefer a combination of the two: Dr Johnson kicked a large rock and said, as his foot rebounded, “I refute it thus.”. as I think it’s weird that a punctuation mark inside a quote can end the sentence that contains the quote. I’d argue like this: in the above case there are two sentences, the quote and the sentence that contains the quote. Both need to be terminated with a period.
If it's important to the writer that what is quoted be identified as a sentence then I agree with you, and I'm going to start using that construction in my writing.
But when it comes to quoting words people say, is often good enough to just quote the words.
When you store a command in a string, to you include the trailing newline? I usually don't, but it'll always depend on the use case.