Skip to content

Commit bf2aef0

Browse files
Initial commit.
0 parents  commit bf2aef0

File tree

11 files changed

+716
-0
lines changed

11 files changed

+716
-0
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: [ArthurSonzogni]

.github/workflows/build.yaml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: Build
2+
3+
on:
4+
create:
5+
tags:
6+
-v*
7+
push:
8+
branches:
9+
- master
10+
pull_request:
11+
branches:
12+
- master
13+
14+
jobs:
15+
test:
16+
name: "Debug build"
17+
strategy:
18+
matrix:
19+
include:
20+
- name: Linux GCC
21+
os: ubuntu-latest
22+
compiler: g++-9
23+
test: true
24+
25+
- name: Linux Clang
26+
os: ubuntu-latest
27+
compiler: clang++
28+
test: true
29+
30+
#- name: MacOS clang
31+
#os: macos-latest
32+
#compiler: clang++
33+
#test: true
34+
35+
#- name: Windows MSVC
36+
#os: windows-latest
37+
#compiler: cl
38+
#test: false
39+
40+
runs-on: ${{ matrix.os }}
41+
steps:
42+
- name: "Checkout repository"
43+
uses: actions/checkout@v2
44+
45+
- name: "Enable MSVC command prompt"
46+
if: matrix.os == 'windows-latest'
47+
uses: ilammy/msvc-dev-cmd@v1
48+
49+
- name: "Install cmake"
50+
uses: lukka/get-cmake@latest
51+
52+
- name: "Build debug mode"
53+
run: >
54+
mkdir build;
55+
cd build;
56+
cmake .. -DCMAKE_CXX_COMPILER=${{ matrix.compiler }};
57+
cmake --build . --config Debug;
58+
59+
# Create a release on new v* tags
60+
release:
61+
needs: test
62+
if: ${{ github.event_name == 'create' && startsWith(github.ref, 'refs/tags/v') }}
63+
name: "Create release"
64+
runs-on: ubuntu-latest
65+
outputs:
66+
upload_url: ${{ steps.create_release.outputs.upload_url }}
67+
steps:
68+
- name: "Create release"
69+
uses: softprops/action-gh-release@v1
70+
id: create_release
71+
with:
72+
draft: true
73+
env:
74+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75+
76+
# Build artifact for the release
77+
package:
78+
name: "Build packages"
79+
needs: release
80+
strategy:
81+
matrix:
82+
include:
83+
- os: ubuntu-latest
84+
asset_path: build/json-tui*Linux*
85+
#- os: macos-latest
86+
#asset_path: build/json-tui*Darwin*
87+
#- os: windows-latest
88+
#asset_path: build/json-tui*Win64*
89+
runs-on: ${{ matrix.os }}
90+
steps:
91+
- name: "Checkout repository"
92+
uses: actions/checkout@v2
93+
94+
- name: "Install cmake"
95+
uses: lukka/get-cmake@latest
96+
97+
- name: "Build packages"
98+
run: >
99+
mkdir build;
100+
cd build;
101+
cmake .. -DCMAKE_BUILD_TYPE=Release;
102+
cmake --build . --config Release --target package;
103+
- uses: shogo82148/actions-upload-release-asset@v1
104+
with:
105+
upload_url: ${{ needs.release.outputs.upload_url }}
106+
asset_path: ${{ matrix.asset_path }}
107+
overwrite: true

CMakeLists.txt

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
cmake_minimum_required (VERSION 3.11)
2+
3+
4+
# Dependencies -----------------------------------------------------------------
5+
6+
include(FetchContent)
7+
set(FETCHCONTENT_UPDATES_DISCONNECTED TRUE)
8+
set(FETCHCONTENT_QUIET FALSE)
9+
10+
FetchContent_Declare(ftxui
11+
GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui
12+
GIT_TAG cdd63398493559238cf7c93bb76a4e6401696db3
13+
GIT_PROGRESS TRUE
14+
)
15+
16+
FetchContent_Declare(json
17+
GIT_REPOSITORY https://github.com/ArthurSonzogni/nlohmann_json_cmake_fetchcontent
18+
GIT_TAG v3.10.4
19+
GIT_PROGRESS TRUE
20+
)
21+
22+
FetchContent_GetProperties(ftxui)
23+
if(NOT ftxui_POPULATED)
24+
FetchContent_Populate(ftxui)
25+
add_subdirectory(${ftxui_SOURCE_DIR} ${ftxui_BINARY_DIR} EXCLUDE_FROM_ALL)
26+
endif()
27+
28+
FetchContent_GetProperties(json)
29+
if(NOT json_POPULATED)
30+
FetchContent_Populate(json)
31+
add_subdirectory(${json_SOURCE_DIR} ${json_BINARY_DIR} EXCLUDE_FROM_ALL)
32+
endif()
33+
34+
# Build ------------------------------------------------------------------------
35+
36+
project(json-tui
37+
LANGUAGES CXX
38+
VERSION 1.0.0
39+
)
40+
41+
add_executable(json-tui
42+
src/main.cpp
43+
src/mytoggle.cpp
44+
src/mytoggle.hpp
45+
)
46+
target_include_directories(json-tui PRIVATE src)
47+
48+
target_link_libraries(json-tui
49+
PRIVATE ftxui::screen
50+
PRIVATE ftxui::dom
51+
PRIVATE ftxui::component
52+
PRIVATE nlohmann_json::nlohmann_json
53+
)
54+
55+
# Install ----------------------------------------------------------------------
56+
57+
install(TARGETS json-tui RUNTIME DESTINATION "bin")
58+
59+
# Package ----------------------------------------------------------------------
60+
61+
if (UNIX AND NOT APPLE)
62+
set(CPACK_GENERATOR "DEB;External;RPM;STGZ;TBZ2;TGZ;TXZ;TZ;TZST;ZIP")
63+
elseif (UNIX AND APPLE)
64+
set(CPACK_GENERATOR "DragNDrop;NuGet;TGZ;ZIP")
65+
elseif (WIN32)
66+
set(CPACK_GENERATOR "DEB;NuGet;TGZ;ZIP")
67+
else()
68+
set(CPACK_GENERATOR "ZIP")
69+
endif()
70+
71+
set(CPACK_DEBIAN_PACKAGE_DEPENDS " ")
72+
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE_URL "https://github.com/ArthurSonzogni/json-tui/")
73+
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Arthur Sonzogni")
74+
set(CPACK_DEBIAN_PACKAGE_VERSION ${PROJECT_VERSION})
75+
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A JSON terminal UI")
76+
set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/ArthurSonzogni/json-tui/")
77+
set(CPACK_PACKAGE_NAME "json-tui")
78+
set(CPACK_PACKAGE_VENDOR "Arthur Sonzogni")
79+
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
80+
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
81+
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
82+
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
83+
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
84+
85+
include(CPack)

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Arthur Sonzogni
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
json-tui
2+
========
3+
4+
![Video](demo.webp)
5+
6+
Features
7+
--------
8+
- **Interactive**: Use keyboard or mouse to scroll/expand objects.
9+
- **Colors**
10+
- **Responsive**: Adapt to the terminal dimensions. Very long text values are
11+
wrapped on several lines.
12+
- The output is displayed inline with the previous commands. Meaning you can
13+
still see the json after leaving json-tui.
14+
- *(Vim users): Also support `j`/`k` for navigation.*
15+
16+
Features for developers
17+
-----------------------
18+
- **simple**: Only 300 line of C++ only. Depends on [FTXUI].
19+
- No dependencies to install. Build simply using CMake.
20+
21+
Build:
22+
------
23+
```bash
24+
mkdir build; cd build
25+
cmake ..
26+
make
27+
sudo make install
28+
```
29+
30+
Package
31+
--------
32+
33+
- Snap package: To be added.
34+
- Deb package: To be added.
35+
- RPM package: To be added.
36+
- Arch linux package: To be added.
37+
- Binaries: To be added.
38+
39+
Authors:
40+
--------
41+
- Arthur Sonzogni
42+
- *You?* (PR are welcomed)
43+
44+
[FTXUI]:https://github.com/ArthurSonzogni/FTXUI

demo.webp

339 KB
Loading

snap/snapcraft.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: json-tui
2+
adopt-info: json-tui
3+
summary: A json visualizer with a terminal UI.
4+
description: A json visualizer with a terminal UI.
5+
6+
grade: stable
7+
confinement: strict
8+
base: core18
9+
10+
apps:
11+
json-tui:
12+
command: json-tui
13+
plugs:
14+
- home
15+
16+
parts:
17+
json-tui:
18+
plugin: cmake
19+
source: https://github.com/ArthurSonzogni/json-tui
20+
source-type: git
21+
build-snaps: [cmake/latest/edge] # We need a modern cmake.
22+
stage-packages:
23+
- git
24+
override-build: |
25+
/snap/bin/cmake \
26+
-DCMAKE_INSTALL_PREFIX=$SNAPCRAFT_PART_INSTALL\
27+
-DCMAKE_BUILD_TYPE=Release \
28+
$SNAPCRAFT_PART_SRC
29+
make -j 4
30+
make install
31+
GIT_TUI_VERSION=`$SNAPCRAFT_PART_INSTALL/bin/json-tui version`;
32+
snapcraftctl set-version "${GIT_TUI_VERSION}"
33+
34+
passthrough:
35+
title: json-tui
36+
license: MIT

src/.clang-format

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Defines the Chromium style for automatic reformatting.
2+
# http://clang.llvm.org/docs/ClangFormatStyleOptions.html
3+
BasedOnStyle: Chromium
4+
Standard: Cpp11

0 commit comments

Comments
 (0)