Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User config file generated from interactive mode contains an incorrect field for line numbers #115

Open
rezarajan opened this issue Jul 5, 2024 · 0 comments

Comments

@rezarajan
Copy link

Describe the bug
When the user.json file is generated from the interactive mode --interactive the field for line numbers is named line_numbers, and is set to false by default. However, this field should be named show_line_numbers as that is what is parsed by the utility.

To Reproduce
Overview: Complete the interactive form on a test file to generate a default user.json config file. Modify the line_numbers field of this config file, and observe the changes in the output.

  1. Create a test file to freeze
echo '{"test": true}' > testfile.json
  1. Freeze the file using interactive mode, naming the file testfile_default.png. Keep this file for comparison.
# Select the testfile.json, and name the output testfile_default.png
# Keep defaults otherwise
freeze --interactive
  1. Open the user.json config. There will be a line_numbers field in the output, which is set to false.
# Output should read "false"
cat ~/.config/freeze/user.json | jq '.line_numbers'

N.b. the default line_numbers field here is the problem, but we continue testing for completeness

  1. Change the line_numbers field value from false to true
# Set the value to true and verify. Output should read "true"
sed -i 's/"line_numbers":false/"line_numbers":true/' ~/.config/freeze/user.json \
&& jq '.line_numbers' ~/.config/freeze/user.json
  1. Freeze the test file again, using this user config, naming it testfile_line_numbers.png
freeze -c user testfile.json --output testfile_line_numbers.png

You will notice that the output file does not contain line numbers, although we changed the line_numbers value from false to true; it is no different than the testfile_default.png file.

  1. Rename the line_numbers field to show_line_numbers
# Output should read "true"
sed -i 's/"line_numbers"/"show_line_numbers"/g' ~/.config/freeze/user.json \
∙ && jq '.show_line_numbers' ~/.config/freeze/user.json
  1. Repeat step 5, naming the output testfile_show_line_numbers.png
freeze -c user testfile.json --output testfile_show_line_numbers.png

You will notice that the line numbers now show, as compared to the other outputs.

Expected behavior
Changing the line_numbers field to true or false should result in line numbers being shown or hidden in the output, respectively. Alternatively, this field should be named show_line_numbers as is consistent with the command-line flag, and is what actually fixes the issue.

Screenshots
testfile_default.png
testfile_default
Default output after running interactive mode

testfile_line_numbers.png
testfile_line_numbers
Output after setting line_numbers to true

testfile_show_line_numbers.png
testfile_show_line_numbers
Output after changing line_numbers to show_line_numbers

Desktop

  • OS: Arch Linux x86_64
  • Version: 0.1.6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant